e830. 向JTabbedPane中加入一个卡片

This example demonstrates various ways to add a tab to a tabbed pane.

    // Create a tabbed pane
    JTabbedPane pane = new JTabbedPane();
    
    // Add a tab with a label taken from the name of the component
    component1.setName("Tab Label");
    pane.add(component1);
    
    // Add a tab with a label at the end of all tabs
    String label = "Tab Label";
    pane.addTab(label, component2);
    
    // Add a tab with a label and icon at the end of all tabs
    Icon icon = new ImageIcon("icon.gif");
    pane.addTab(label, icon, component3);
    
    // Add a tab with a label, icon, and tool tip at the end of all tabs
    String tooltip = "Tool Tip Text";
    pane.addTab(label, icon, component4, tooltip);
    
    // Insert a tab after the first tab
    int index = 1;
    pane.insertTab(label, icon, component5, tooltip, index);

 

Related Examples
posted @ 2018-09-06 09:13  borter  阅读(111)  评论(0编辑  收藏  举报