| Author |
Problems using JTabbedPane In a GUI application
|
Rudy Rodriguez
Greenhorn
Joined: May 01, 2009
Posts: 29
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Rudy Rodriguez
Greenhorn
Joined: May 01, 2009
Posts: 29
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
You just shifted the problem.
Those 4 JLabels still can have only one parent, and that's the last created topPanel.
|
 |
Rudy Rodriguez
Greenhorn
Joined: May 01, 2009
Posts: 29
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Simply create the JLabels just like you create the panels inside the loop.
|
 |
Rudy Rodriguez
Greenhorn
Joined: May 01, 2009
Posts: 29
|
|
Rob,
Thank You....
I followed your advice..
I got it working..
|
 |
 |
|
|
subject: Problems using JTabbedPane In a GUI application
|
|
|