Article View: borland.public.jbuilder.java.language
Article #17500Re: Three-state checkbox?
From: Max Polk
Date: Wed, 04 Nov 1998 00:00
Date: Wed, 04 Nov 1998 00:00
22 lines
1505 bytes
1505 bytes
In article <71qg51$bin25@forums.borland.com>, jasonb@tmscorp.com says... > I was wondering if anyone had figured out how to make a checkbox (either > AWT, Swing, or JBCL) have three states (checked, unchecked, and null). This > seems pretty critical for any database entry screen, so I must be missing it > somewhere. You can do this trick, where the button appears as if it were in the middle of being pressed to get the "grayed out" appearance. Here, you can set the variable "desiredState" so the checkbox is grayed out checked or grayed out unchecked. I set the pressed state false first because it gets confused otherwise and progresses to the next state as if it really were pressed: boolean desiredState = false; jCheckBoxLimitChange.getModel ().setPressed (false); jCheckBoxLimitChange.getModel ().setSelected (desiredState); jCheckBoxLimitChange.getModel ().setPressed (true); You can also use images added to a JLabel rather than using a checkbox at all. Add one of three appropriate images (checked, unchecked, null).
Technical Details
Message-ID:
<MPG.10aa9631b844ee699896b2@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<71qg51$bin25@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,bcf97e9488b3bfed X-Google-Attributes: gidf74b3,public From: none@none.com (Max Polk) Subject: Re: Three-state checkbox? Date: 1998/11/04 Message-ID: <MPG.10aa9631b844ee699896b2@forums.borland.com> X-Deja-AN: 408437802 References: <71qg51$bin25@forums.borland.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language