Search code examples
javaswingjcomboboxjtabbedpane

Bring a Tab held within a JTabbedPane to the front?


So, my question is: When select the "Perimeter" from the JComboBox, how would I go about making so that tab(held within the JTabbedPane) comes to the front? and likewise with area or other Tabs.

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    String selectedItem = jComboBox1.getSelectedItem().toString();

    if(selectedItem != null)
    {
        //if perimeter option selected, show the tab for it
        if(selectedItem.equals("Perimeter"))
        {
            //bring the permeter tab to the front, all contained within a tabbedPane
        }

        if(selectedItem.equals("Area"))
        {
            //bring the area tab to the front, all contained within a tabbedPane
        }
    }
} 

Solution

  • You could use it as a show and not show option, so that if they select perimeter it shows the perimeter information in the tabbed pane.

    frame.setVisible(true);
    

    or if you are looking to put this tabbed pane on top of the other you can try: Java Swing - how to show a panel on top of another panel?