aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes what will happen while adding already existing panel in JTabbedPane? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "what will happen while adding already existing panel in JTabbedPane?" Watch "what will happen while adding already existing panel in JTabbedPane?" New topic
Author

what will happen while adding already existing panel in JTabbedPane?

mohan rajv
Ranch Hand

Joined: Jan 28, 2009
Posts: 30
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

Joined: Jul 26, 2007
Posts: 10386
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
mohan rajv
Ranch Hand

Joined: Jan 28, 2009
Posts: 30
@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

Joined: Jul 26, 2007
Posts: 10386
    
    8

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

Joined: Jan 28, 2009
Posts: 30
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..
 
wood burning stoves
 
subject: what will happen while adding already existing panel in JTabbedPane?