Solved

Stop changing tabs in a JTabbedPane

Posted on 2006-06-22
7
717 Views
Last Modified: 2008-01-09
Hi,

I'm using a JTabbedPane and at some point, I need to prevent it from leaving a particular tab (due to a condition), even though the user wants to go to a different  tab . Is this possible with JTabbedPane. I also want to make sure that stateChanged listener doesn't get called.

Thanks
0
Comment
Question by:anthony0007
7 Comments
 
LVL 14

Accepted Solution

by:
hoomanv earned 32 total points
ID: 16961190
you can disable the other tabs so he cant move to them
using JTabbedPane.setEnabledAt(int index, boolean enabled)
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 31 total points
ID: 16961334
Personally i wouldn't do that. Your users will probably just think your ui is broken
0
 

Author Comment

by:anthony0007
ID: 16961626
Isn't there any other way to prevent it from moving to other tabs. stateChanged Listener gets called once the tab has been changed.
If I can capture an event before tab changes, then it might be helpful.
0
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 31 total points
ID: 16963904
Well I can only see to option :

1. Either disable the item or
2. Blast a JOptionPane if he goes to other tabs while there is unfinish
task this will not allow him to go to the next tab if you trap it with
a dialog to remind him.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 31 total points
ID: 16964567
yyou would disable the other tabs as hoomanv suggested.
then reenable them when they are allowed to change again.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
MySQL  on Tomcat 8 68
SHA2 certs for IIS AND Java? 2 113
ejb example issues 3 23
Eclipse Java import and method not resolved 4 48
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

856 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