Article View: borland.public.jbuilder.java.swing
Article #1068Re: how to do a JList filled with JCheckboxes?
From: George
Date: Tue, 04 May 2004 21:55
Date: Tue, 04 May 2004 21:55
29 lines
1763 bytes
1763 bytes
You can implement your own javax.swing.ListCellRenderer for the JList and implement the getListCellRendererComponent method to return a check box. The check box comes with its own label (see setText() method); so you don't need to handle that separately. ListCellRender is an interface. DefaultListCellRenderer is a concrete class that extends JLabel. HTH. "Sam Seaborn" <sam@rightclick.ca> wrote in message news:40980aed$1@newsgroups.borland.com... > Hi, > > I'm trying to do a JList of JCheckboxes (like in JBX's 'close projects' > dialog box). > > I have implemented a JTable with two columns, one for the checkbox and one > for the label. But it's not exactly what I want, and not as nice as JBX's. > > Also, I tried dynamically GridBagLayout-ing JCheckBoxes on a JPanel to > duplicate the behaviour, but that turned out even worse. > > How would you Swing gurus do it? > > Sam > >
Technical Details
Message-ID:
<409810e5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40980aed$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,e278b4d50586b83 X-Google-Attributes: gid111d45,public From: "George" <geo_54321@yahoo.com> Newsgroups: borland.public.jbuilder.java.swing References: <40980aed$1@newsgroups.borland.com> Subject: Re: how to do a JList filled with JCheckboxes? Date: Tue, 4 May 2004 17:55:15 -0400 Lines: 31 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 63.119.115.129 Message-ID: <409810e5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083707621 63.119.115.129 (4 May 2004 14:53:41 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail