This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting tab on JTabbedPane that exists already

 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUI forum.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Runnable,serializable,and Collections are cool but I'll have to go with the desktopPane solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic