• 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

How to set name of jPanel into jTabbedPane?

 
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, how can I set name for a jPanel which is into a jTabbedPane from code? I tryed with panel.setName("name") but it does not work and it remains empty.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

What does the Component#setName() method do? It means the Component has a name, but it doesn't say anything about displaying the name. That method appears not to have been overridden in JP‍anel. A panel doesn't usually have writing on, and it has no setText method. I suggest you add a JLabel (or a text component) to the panel. A JL‍abel has a constructor to set the text, or you can set the text later with this method.
 
Stefano Castiglia
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch
. . . .



ok, but I mean to change tab's name (label0, label1...) from code, because now name is written with intellij idea gui editor
Schermata-2016-12-30-alle-12.25.20.png
[Thumbnail for Schermata-2016-12-30-alle-12.25.20.png]
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will have to provide more details about the GUI builder before we can help.

Don't quote the whole of the old post, which simply duplicates things without adding anything.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefano Castiglia wrote:
ok, but I mean to change tab's name (label0, label1...) from code, because now name is written with intellij idea gui editor


No idea about the GUI builder (never used one) but if you write code, all you need to do is

 
Stefano Castiglia
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:You will have to provide more details about the GUI builder before we can help.

Don't quote the whole of the old post, which simply duplicates things without adding anything.



I'm using intellij idea, I had created a GUI form which contains form and its class. In my form I added some stuff graphically, tree into attachments. Because my project has to support multiple languages I need to set different label for different languages, but the only way to access to those panels is using the class, examples into attachments.
Schermata-2016-12-30-alle-13.22.18.png
[Thumbnail for Schermata-2016-12-30-alle-13.22.18.png]
tree
Schermata-2016-12-30-alle-13.23.02.png
[Thumbnail for Schermata-2016-12-30-alle-13.23.02.png]
example
 
Stefano Castiglia
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Final solution:
refer to jTabbedPane and use setTitleAt(#panel, string)

Example:
tbdpnl_languages.setTitleAt(0, lang.getWord("pnl_en"));
tbdpnl_languages.setTitleAt(1, lang.getWord("pnl_it"));
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting your solution, Stefano! I gave you a cow for that.
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic