e828. 创建JTabbedPane

A tabbed pane is a container that displays only one child component at a time. Typically, the children are themselves containers of other components. Each child is associated with a visible tab on the tabbed pane. The user can choose a child to display by selecting the tab associated with that child.

    // Create a child container which is to be associated with a tab
    JPanel panel = new JPanel();
    // Add components to the panel...
    
    // Specify on which edge the tabs should appear
    int location = JTabbedPane.TOP; // or BOTTOM, LEFT, RIGHT
    
    // Create the tabbed pane
    JTabbedPane pane = new JTabbedPane();
    
    // Add a tab
    String label = "Tab Label";
    pane.addTab(label, panel);

 

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