0

I am using JtabbedPane which contains several jTextPanes like jTextPane1,lTextPane2...etc. NOw I want to perform some actions during the selection of a partiular tab. eg: I want to enable a button if I select jTextPane 2.. Now I am able to identify selected Component of Tab.ie: jTextPane. But I am not able to identify which jTextPane is selected(Which object of jTextPane).. How can I resolve it ..? Can any one help me? plz..

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by ajst
0

to find out which pane is selected try using getSelectedIndex() which will tell you which pane is currently selected.

try using something like this if you want the code to be ran as soon as that pane has been selected.

private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        if( jTabbedPane1.getSelectedIndex()== 0)
        {
            function1();
        }
        if( jTabbedPane1.getSelectedIndex()== 1)
        {
            function2();
        }
    }

    private void function1()
    {
       jTabbedPane1.setBackground(Color.red);
    }
    private void function2()
    {
        jTabbedPane1.setBackground(Color.green);
    }

I've not used Tabbed Panes before so this might not be the best way of doing it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.