Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Swing / AWT / SWT
Getting the name or text field from an Object
Richard Alves
Greenhorn
Posts: 12
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
public void itemStateChanged(ItemEvent e) { int out_kitchen_cnt = 0; String out_bro = ""; Object out_kitchen[] = new Object[out_bros]; if(e.getStateChange() == ItemEvent.SELECTED){ System.out.println(e.getSource()); out_kitchen[out_kitchen_cnt] = e.getSource(); out_bro = e.getSource().getText(); } if(e.getStateChange() == ItemEvent.DESELECTED){ } }
Michael Dunn
Ranch Hand
Posts: 4632
posted 12 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
you'd just need to cast the object as a JCheckBox
change
e.getSource().getText();
to
((JCheckBox)e.getSource()).getText();
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
null pointer again!
JCheckBox and File IO *Help*
Problem in JTable row selection
JTable with custom checkbox cell editor - problem with the table MouseListener
JCheckBox and File IO **Help**
More...