Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How do you make a check box work with a JButton?

 
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hey Everyone,

I'm working with JCheckBox for the first time and I'm stuck at the moment. I would like to know how do you make a JCheckBox work with a JButton?

Example on how I would like my program to work. When the user choose a check box, I only want it to perform an action when the enter button is press.



Thank for the help everyone.
 
Phillip Larson
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Update: It seem I've got it working

 
Marshal
Posts: 65085
247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you been through the Java™ Tutorials? It has a section about check boxes. Here's the link.
 
Phillip Larson
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You
 
Campbell Ritchie
Marshal
Posts: 65085
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avoid action commands like the plague. You should have one listener object per action required, so don't make a display component implement action listener.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!