Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one button enabled/disabled when some other button pressed/not pressed

 
Castor Tack
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there:

How can I do what the title says?

For example, I create three buttons: "Edit Mode", "Watch Mode", "Draw Shape"

I know that I need to use toggle button for the first two (user can be in only one mode at a time).

What I want is, all three buttons are shown on a GUI, but the third button is activated (for users to press) ONLY when the first toggle button is pressed.

What button type should I use to define "Draw Shape"? And How?

If there's any link to how I do it, it's also appreciated.

Thank you.
 
Paul Clapham
Sheriff
Pie
Posts: 20953
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An ordinary JButton would be fine for the "Draw Shape" button. It should initially be turned off, but you should have an ActionListener on the other buttons which turns it on and off depending on what state is set for them.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More about that here:
http://download.oracle.com/javase/tutorial/uiswing/components/button.html
 
Castor Tack
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. I got it done.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic