Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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