• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems using JTabbedPane In a GUI application

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?


 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob,
Thank You....
I followed your advice..

I got it working..

 
reply
    Bookmark Topic Watch Topic
  • New Topic