Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton in JPanel  RSS feed

 
Jatin sachdev
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JButton is added into JPanel
Want to know the name of the object of JPanel when this button is clicked?

For e.g.

I have made a JPanel in which there is one JButton.Now I added two objects of this JPanel into JFrame.
is it possible to know the name of JPanel object when Jbutton in that panel is clicked?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects don't have names, unless you set one with the setName(String name) method. If you did, you can get the name of the panel in the button's ActionListener's actionPerformed(ActionEvent e) with
 
Jatin sachdev
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks...............its now working....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!