Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what will happen while adding already existing panel in JTabbedPane?

 
mohan rajv
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what will happen while adding already existing panel in JTabbedPane?

i have already added a panel Object in JTabbedPane.if i add the same panel again what will happen ?
and while adding panel i want to check whether a panel is exists in tat jtabbedpane or not..how to check tat..
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohan rajv wrote:what will happen while adding already existing panel in JTabbedPane?
i have already added a panel Object in JTabbedPane.if i add the same panel again what will happen ?
and while adding panel i want to check whether a panel is exists in tat jtabbedpane or not..how to check tat..


How difficult is it to try out on your own and see? Takes less time than posting here doesn't it?
Check out JTabbedPane#getComponentAt(int index). If no panel exists you would get null.
 
mohan rajv
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Maneesh Godbole

i dont know the index of that panel.i have that panel object.and i have the jtabbedpane object.i want to check whether that panel is already there in my jtabbedpane or not..what should i do now?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not need to know the index of the panel.
Just iterate through all the tabs (check out the API to figure out how to find out the tab count). Once you retrieve the Object at some specific index, check if it is the same panel you want and process accordingly.

Did you check out if you can add the panel twice? What result did you get?
 
mohan rajv
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i add the same panel object again it is replacing the old one with that.i tried to add with new title it replaced the old one.

and i got a solution for my problem..instead of comparing the panel objects now i am comparing the panel titles.that s easy one..
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic