🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #111

Re: Help to solve flickering Checkbox in JTable

#111
From: perry
Date: Sat, 01 May 2004 21:43
45 lines
3034 bytes
what version of jdk are you using?

Ben Munday wrote:
> Hi all,
>     I have a problem with a Checkbox in a JTable.
> When i add the Checkbox into the JTable it displays the String 
> representation of the Checkbox, which is not what i want.
> So, i created a CheckBoxRenderer which extens Checkbox and implements 
> TableCellRenderer. This seems to have done the job, in that the Checkbox 
> is displayed and not the String representation. But, and it's a big 
> 'but', the column that holds the Checkbox continually updates the 
> fields. I cannot select the Checkbox and i can only just see that the 
> correct info for the Checkbox is in the cell.
> I think it has something to do with repainting the Checkbox, but i can't 
> figure out how to stop it from happening.
> 
> Here is some of the code, the bit's i think are relevent:
> All code is at:
> http://www.users.on.net/benmunday/Label/
> 
> 
> 
> public class CheckBoxRenderer extends Checkbox implements TableCellRenderer
> {
> 
> ...
> 
>     public Component getTableCellRendererComponent(JTable table, Object 
> cBox, boolean isSelected, boolean hasFocus, int row, int column)
>     {
>         Checkbox newCheckbox = (Checkbox)cBox;
>         newCheckbox.setState(false);
>         return newCheckbox;
>     }
> }
> 
>     JTable itemDataTable = new JTable(new MyTableModel(data));
>     itemDataTable.setDefaultRenderer(data[0][0].getClass(), 
> new                          CheckBoxRenderer());
> 
>     itemDataScrollPane.getViewport().setView(itemDataTable);
>     itemDataScrollPane.setVisible(true);
> 
>     contentPane.add(itemDataScrollPane,  BorderLayout.CENTER);
> 
Technical Details
Message-ID: <OTTkc.57237$OU.1418200@news20.bellglobal.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail
References: <400613be$1@duster.adelaide.on.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,93a0ed3014c56a0
X-Google-Thread: 113ae9,93a0ed3014c56a0
X-Google-Thread: fecd1,93a0ed3014c56a0
X-Google-Thread: 10fd6d,93a0ed3014c56a0
X-Google-Attributes: gid10d6db,gid113ae9,gidfecd1,gid10fd6d,public
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail
From: perry <perry@unifiedobjects.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: aus.computers.java,comp.lang.java.help,comp.lang.java.api,comp.lang.java.gui
Subject: Re: Help to solve flickering Checkbox in JTable
References: <400613be$1@duster.adelaide.on.net>
In-Reply-To: <400613be$1@duster.adelaide.on.net>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 46
Message-ID: <OTTkc.57237$OU.1418200@news20.bellglobal.com>
Date: Sat, 01 May 2004 17:43:48 -0400
NNTP-Posting-Host: 142.177.243.210
X-Complaints-To: abuse@sympatico.ca
X-Trace: news20.bellglobal.com 1083443822 142.177.243.210 (Sat, 01 May 2004 16:37:02 EDT)
NNTP-Posting-Date: Sat, 01 May 2004 16:37:02 EDT
Organization: Bell Sympatico