• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTabbePane and tab indeces

 
Malcolm White
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have an application that creates a JLabel for each tab in a JTabbedPane in which it stores various data about that specific tab's components.

The JLabels are stored in a Vector and their positions are mapped to the indeces of the tabs. All works well until a tab is closed, which is when all the indeces change. This doesn't happen with the last tab of course.

Is there any way of preventing Swing from resetting the tabs' indeces? Or does someone have any ideas about an alternative design strategy for mapping the two?

Thanks for any pointers.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An easy answer might be to extend JTabbedPane and override the method that you are using to remove tabs (remove(int index) ?).

something like ....

Vector labelVector = ...;

public void remove(int index) {
super(int);
labelVector.remove( index );
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!