• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTabbePane and tab indeces

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 );
}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic