How can one obtain the state of a JCheckbox? I want to know if it is
checked or unchecked, not when it is clicked.
Thanks
Allan
Lasse Reichstein Nielsen - 20 Jun 2004 11:12 GMT
> How can one obtain the state of a JCheckbox? I want to know if it is
> checked or unchecked, not when it is clicked.
<URL: http://java.sun.com/j2se/1.4.2/docs/api/ >
Follow the link "How to Use Buttons, Check Boxes, and Radio Buttons":
Below the heading "Implementing the Button's Functionality" you find
a reference to "isSelected":
<URL: http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/AbstractButton.html#isSelected() >
Good luck
/L

Signature
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Kova - 20 Jun 2004 11:19 GMT
> How can one obtain the state of a JCheckbox? I want to know if it is
> checked or unchecked, not when it is clicked.
Well when it's clicked just register it into some variable like boolean.
example, set it to non-checked at start:
...if clicked code...
...change(cb_clicked); where cb_cliked is boolean
since boolean is ordered type with 2 values I assume you can somehow switch
between true and false with some method that increases or decreases a value.
I don't exactly know what it is in Java.
--
Kova
Roedy Green - 20 Jun 2004 12:54 GMT
>How can one obtain the state of a JCheckbox? I want to know if it is
>checked or unchecked, not when it is clicked.
see http://mindprod.com/jgloss/jcheckbox.html

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.