File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes setEnabled (false) doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setEnabled (false) doesn Watch "setEnabled (false) doesn New topic

setEnabled (false) doesn't work

Matthew Helling

Joined: Mar 18, 2004
Posts: 17
I've got a problem and I'm stumped. I have 2 snippets of code (they are checkboxes) and when checked, should disable another checkbox.
The problem is, only one of them works. I've looked at the code a hundred times and can't figure it out.
Also, in a perfect world unchecking the box would "un-gray" the other option. That doesn't work, but I was able to add code to the reset button which will enable all checkboxes.
Please take a look and offer any advice you can.
Matthew Helling

Joined: Mar 18, 2004
Posts: 17
ok, I found the bug, this is really weird.
Because in my server declarations I never had Email Server = false, the code wouldn't run for checking the box. once i set one of the server objects to false, it started working.
goofy. hope someone learns something.
I could still use some help un-graying boxes if anyone has any ideas. When I uncheck the box, it "Undos" the other effects, but not the setEnabled (false).

[ March 24, 2004: Message edited by: Matthew Helling ]
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Instead of using setEnabled( false ), you could base the boolean value off whether the current checkbox is checked. After you're finished with all the tests, have something like this -

[ March 25, 2004: Message edited by: Nathan Pruett ]

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
jQuery in Action, 3rd edition
subject: setEnabled (false) doesn't work
It's not a secret anymore!