xenia27
asked on
disable JTabbedPane
Hi,
I have a JTabbedPane with 3 JPanels and one JTabbedPane...
JTabbedPane main = new JTabbedPane();
JPanel a1 = new JPanel();
JPanel a2 = new JPanel();
JPanel a3 = new JPanel();
JTabbedPane b_main = new JTabbedPane();
JPanel b1 = new JPanel();
JPanel b2 = new JPanel();
main.add("a1", a1);
main.add("a2", a2);
main.add("a3", a3);
main.add("b menu", b_main);
b_main.add("b1", b1);
b_main.add("b2", b2);
If I have two JButtons, button1 and button2, in my b1...and when I click button1, I will process some function, at the same time, I don't want users to change tabs...how can I do so??
I have a JTabbedPane with 3 JPanels and one JTabbedPane...
JTabbedPane main = new JTabbedPane();
JPanel a1 = new JPanel();
JPanel a2 = new JPanel();
JPanel a3 = new JPanel();
JTabbedPane b_main = new JTabbedPane();
JPanel b1 = new JPanel();
JPanel b2 = new JPanel();
main.add("a1", a1);
main.add("a2", a2);
main.add("a3", a3);
main.add("b menu", b_main);
b_main.add("b1", b1);
b_main.add("b2", b2);
If I have two JButtons, button1 and button2, in my b1...and when I click button1, I will process some function, at the same time, I don't want users to change tabs...how can I do so??
This can certainly help:
void setEnabledAt(int index, boolean enabled) : Sets whether or not the tab at index is enabled.
void setEnabledAt(int index, boolean enabled) : Sets whether or not the tab at index is enabled.
>> I don't want users to change tabs
So you could disable all tabs:
for (int i=0; i<main.getTabCount(); i++)
main.setEnabledAt(i, false);
And afterwards enable them again (replace false by true in the above)
So you could disable all tabs:
for (int i=0; i<main.getTabCount(); i++)
main.setEnabledAt(i, false);
And afterwards enable them again (replace false by true in the above)
Do u want to display any tab strip when user clicks on button?
if so, then
suppose u want to show the panel, 'a1' when uer clicks button.
main.setSelectedComponent( a1);
OR
main.setSelectedIndex(0)
if u want to disable then
main.setEnabled(true)
Naeem Shehzad Ghuman
if so, then
suppose u want to show the panel, 'a1' when uer clicks button.
main.setSelectedComponent(
OR
main.setSelectedIndex(0)
if u want to disable then
main.setEnabled(true)
Naeem Shehzad Ghuman
>>if u want to disable then // *disable*
>>main.setEnabled(true) // true???
>>main.setEnabled(true) // true???
this should be sufficient no need to go for each tab.
in action performed set false once processing is over then enable tab by setting true flag.
setEnabled(boolean enabled)
in action performed set false once processing is over then enable tab by setting true flag.
setEnabled(boolean enabled)
ASKER
mMm...I'm confused...
OK...I have two layers of JTabbedPane, right? And when I click on button1 which is in b1...I would like to disable all other tabs...a1, a2, a3, and b2...the only thing will work is button1 and button2...
If I would like to use setEnabledAt, should I do this?
main.setEnabledAt(index, false); and b_main.setEnabledAt(index, false); right???
OK...I have two layers of JTabbedPane, right? And when I click on button1 which is in b1...I would like to disable all other tabs...a1, a2, a3, and b2...the only thing will work is button1 and button2...
If I would like to use setEnabledAt, should I do this?
main.setEnabledAt(index, false); and b_main.setEnabledAt(index,
ASKER
OK...I got what I want with setEnabledAt...but I'm confused about the index part...
I mean the second layer....how can I count the index? like what's the index number of b2???
I mean the second layer....how can I count the index? like what's the index number of b2???
>>b_main.add("b1", b1);
>>b_main.add("b2", b2);
The index of b2 in b_main is 1 (of b1 is 0)
>>b_main.add("b2", b2);
The index of b2 in b_main is 1 (of b1 is 0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK...I got it...Thanks~~~~~ ^__^
Thank you
you would have done it by setting the tabbedpane to flag false and true.
main.setEnabled(false);
helps.