• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems using JTabbedPane In a GUI application

 
Rudy Rodriguez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I making a GUI application, that uses JTabbedPane.
Each of the tab panes need to contain the same Jlabels.
I will add textboxes with specific information, once the Tab GUI's are completed.
I created button objects, they seem to appear correctly on the tab panes.
But the labels seem to not appear, on the other tab panes.

I am having problems in that the labels display on the last tab created, and not on the others.

I have included my code below.

Can anyone help ?


 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each component can only be added to one single parent component. So when you're calling that only works with one of the tab panels. All the others will not have the same panel. You'll need to create a new locinfoPanel with all of its contents for each tab you want to add it to.
 
Rudy Rodriguez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob.

I tried running my code with the modified for loop below, It had no effect to the GUI.
The panel with the locinfoPanel only displayed on the last tab panel.

In the loop I create a new locinfoPanel, and insert the labels each run through the loop.

Can you give me any suggestions..

Thanks

 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just shifted the problem.
Those 4 JLabels still can have only one parent, and that's the last created topPanel.
 
Rudy Rodriguez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
I understand what you are saying in regards to the labels having one parent.
And that parent would be displayed on the last tab created.

I am unsure as to how to be able to dynamically create multiple parents to be displayed on multiple tab panes.

I have tried to attach a index or counter to my parent topPanel, such as topPanel[index].
The IDE treated this as trying to create a array.

How can I solve my problem ??

Thanks

 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply create the JLabels just like you create the panels inside the loop.
 
Rudy Rodriguez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
Thank You....
I followed your advice..

I got it working..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic