Article View: borland.public.jbuilder.java.swing
Article #12227Re: JList and JCheckBox
From: Vasudevan Srinivasan
Date: Mon, 01 Feb 1999 00:00
Date: Mon, 01 Feb 1999 00:00
40 lines
2311 bytes
2311 bytes
Hi,
Thanks for suggestion. But I dont have the list box tied to a database. The
items are a vector. And Im using JList. I have already done it with JTable
and it works fine.
The code is something like this:
public void getListCellRenderer([...], boolean isSelected, boolean
cellHasFocus) {
...
}
When I click on the checkbox this method is called 3 times
1. isSelected & cellHasFocus are false for the old item
2. isSelected & cellHasFocus are true for new item (mousePressed)
3. isSelected & cellHasFocus are true for new item (mouseReleased)
(Since both isSelected & cellHasFocus are always same, there is really ONE
variable which represents the current state which is same for both
mousePressed and mouseReleased. So it basically works like an option-list box
not checklist.) And its also called when you switch to another window and
reactivate this and all of them are repainted. This behaviour is reported as
a bug in bug-parade 4129312 but is closed, because its actually not a bug. it
is just the behaviour of UIManager calling its cells makes it not so easy to
code "in a pure object-oriented manner". Iow it is just not sufficient to use
the internal value of the JCheckBox itself to check/uncheck itself. I tried
capturing the mouse-events but it doesnt help. There were a few sites with
exactly the same problem presented but without solution.
Vasu
Vladimir Olenin wrote:
> Hi, Vas,
>
> Can't say smth definite, but if i'm not mistaken, you should do smth
> with data. To annouce that it's boolean. There is a good tutorial on how
> to embed checkbox in JTable on javasoft site. The turorial is really
> great.
>
> Thought it could help,
>
> Vladimir
Technical Details
Message-ID:
<36B5BF85.5B969DAD@netrisk.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36B11588.99200A76@worldnet.att.net> <36B393E7.34F257A5@collegemail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,944f205c85217f2b X-Google-Attributes: gid111d45,public From: Vasudevan Srinivasan <vasudevan@netrisk.com> Subject: Re: JList and JCheckBox Date: 1999/02/01 Message-ID: <36B5BF85.5B969DAD@netrisk.com> X-Deja-AN: 439384475 Content-Transfer-Encoding: 7bit References: <36B11588.99200A76@worldnet.att.net> <36B393E7.34F257A5@collegemail.com> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing