Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I locate the instance name for a swing widget?

 
Calvin Hwang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example
jButton1 = new JButton();
How do I code something for
jButton.???
to return to me the string "jButton1"?
It is the bit of ??? that has me stumped.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Calvin.
If you mean the name of the instance variable, it can be found out with reflection.
If you mean the name field of awt.Component it can be accessed by getName and setName.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!