开发者

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 p开发者_StackOverflowerimeter 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
        }
    }
} 


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?


I think you might be looking for this: http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#setSelectedIndex%28int%29

TabbedPane .setSelectedIndex(int)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜