Article View: borland.public.jbuilder.java.swing
Article #12872Re: Changing cell foreground after edit
From: Max Polk
Date: Wed, 28 Oct 1998 00:00
Date: Wed, 28 Oct 1998 00:00
21 lines
1405 bytes
1405 bytes
In article <36362FDE.D930161F@prb.net>, rmazyck@prb.net says...
> I want to change the foreground of the cellRenderer when the data in
> the cell has been chaged. I subclassed the JTable and overwrote
> several methods. Can some tell me what I am missing.
Create a class that implements TableCellRenderer. It simply has to
provide:
public Component getTableCellRendererComponent (JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column);
Typically you create a JLabel and make the text value.toString(). At
that point you can set the JLabel's foreground and background color. You
have to make the JLabel opaque if you want to see the background color.
Then you take your table, get the column you are specializing, and set
its cell renderer to be an instance of the class you created above:
myJTable.getColumn (whatever).setCellRenderer (myTableCellRenderer);
Technical Details
Message-ID:
<MPG.10a12a6fabf0e6189896a8@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36362FDE.D930161F@prb.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,92725cedc5e8d089 X-Google-Attributes: gid111d45,public From: none@none.com (Max Polk) Subject: Re: Changing cell foreground after edit Date: 1998/10/28 Message-ID: <MPG.10a12a6fabf0e6189896a8@forums.borland.com> X-Deja-AN: 406009309 References: <36362FDE.D930161F@prb.net> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing