[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

disable JTabbedPane

Posted on 2004-10-12
13
Medium Priority
?
496 Views
Last Modified: 2012-05-05
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??
0
Comment
Question by:xenia27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12284742
First, try if

         main.setEnabled(false);

helps.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12284767
This can certainly help:

       void setEnabledAt(int index, boolean enabled) : Sets whether or not the tab at index is enabled.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12284784
>> 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)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Expert Comment

by:Naeemg
ID: 12284810
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
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12284845
>>if u want to disable then           // *disable*
>>main.setEnabled(true)             // true???


0
 
LVL 6

Expert Comment

by:expertmb
ID: 12284911
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)
0
 

Author Comment

by:xenia27
ID: 12284929
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???
0
 

Author Comment

by:xenia27
ID: 12285048
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???
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12285087
>>b_main.add("b1", b1);
>>b_main.add("b2", b2);

The index of b2 in b_main is 1 (of b1 is 0)
0
 
LVL 37

Accepted Solution

by:
zzynx earned 1000 total points
ID: 12285099
So, when clicking the button:

for (int i=0; i<main.getTabCount(); i++)
    main.setEnabledAt(i, false);

b_main.setEnabledAt(1, false);  // to disable b2
0
 

Author Comment

by:xenia27
ID: 12285100
OK...I got it...Thanks~~~~~  ^__^
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12285111
Thank you
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12285116
you would have done it by setting the tabbedpane to flag false and true.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question