Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 724
  • Last Modified:

Stop changing tabs in a JTabbedPane

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
anthony0007
Asked:
anthony0007
4 Solutions
 
hoomanvCommented:
you can disable the other tabs so he cant move to them
using JTabbedPane.setEnabledAt(int index, boolean enabled)
0
 
CEHJCommented:
Personally i wouldn't do that. Your users will probably just think your ui is broken
0
 
anthony0007Author Commented:
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
 
JavatmCommented:
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
 
objectsCommented:
yyou would disable the other tabs as hoomanv suggested.
then reenable them when they are allowed to change again.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now