• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting the name or text field from an Object

 
Richard Alves
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I am building an application that has a group of JCheckBox I want to get the label of the JCheckBox in order to use that value. I am unsure how to go about this. I have tried using getName() and other things but nothing is really working.

Thanks in advance for your help.


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you'd just need to cast the object as a JCheckBox

change
e.getSource().getText();

to
((JCheckBox)e.getSource()).getText();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!