aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Setting tab on JTabbedPane that exists already Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting tab on JTabbedPane that exists already" Watch "Setting tab on JTabbedPane that exists already" New topic
Author

Setting tab on JTabbedPane that exists already

James Howerton
Ranch Hand

Joined: Mar 14, 2009
Posts: 82
Hello
How can I add a tab to a JTabbedPane that exist?
NullPointer
This method adds tabs to a JTabbedPane but I need it to add the tab to a
JTabbedPane that was created at startup in the SetObjects class.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Moving to our GUI forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Howerton
Ranch Hand

Joined: Mar 14, 2009
Posts: 82
Is it possible to use the Interface Runnable here?

my tabs are loading with a hard coded Array now.

if it is a sound practice
I am working on classes that will use a list and kind of update that array so it will have different elements added or removed.

additionally, If I create a class to r/w that list and maintain a properties.properties will this allow the same tabs to load when I restart the program?

finally, Is it possible to make the panels that load into the tabpane serializable so I can look them up using properties or will the load on the tabbed panels automatically?

>
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you're still working on this problem

> How can I add a tab to a JTabbedPane that exist?
> NullPointer

you have as a class field
public JTabbedPane jTabbedPaneObj;

and in obj(), you have this
JTabbedPane jTabbedPaneObj = new JTabbedPane();

if you try to access jTabbedPaneObj from elsewhere in your code, it will be null

change
JTabbedPane jTabbedPaneObj = new JTabbedPane();
to
jTabbedPaneObj = new JTabbedPane();
James Howerton
Ranch Hand

Joined: Mar 14, 2009
Posts: 82
The Runnable,serializable,and Collections are cool but I'll have to go with the desktopPane solution.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting tab on JTabbedPane that exists already