Create a table cell renderer which renders the appropriate color
based upon the last character ("/" or *), and make it the cell
renderer for the column in question. An online exampe which
does something similar is ...
http://www2.gol.com/users/tame/swing/examples/src/table/BorderCellRenderer.java
Gary Schaps
[EMAIL PROTECTED] wrote:
>
>
> Message: 6
> Date: Tue, 27 Mar 2001 16:44:31 -0800
> From: Ravi Prakash <[EMAIL PROTECTED]>
> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>,
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: how to change color for cell in a column
>
> Hi,
>
> i have a table with two columns which displays date and dir structure
>
> Date Dir
> 2001-03-20 /ravi/
> 2001-03-21 /test/temp
>
> The scenario is the table displays the data in black color.
> I want to change the color for the data in Dir column to yellow which
> ever ends with /.
> So the /ravi/ should be displayed with yellow color and /test/temp
> should be displayed with default color.
>
> Could any one suggest how to do this.
>
> Thx in advance
>
> --__--__--
>
> Message: 7
> Date: Wed, 28 Mar 2001 03:36:30 -0000
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: JTable Return key and Cell Validation Q's
>
> Hi
> I am trying to do a JTable that once the last cell in the last row is
> edited and the user hits the return key, a new row is inserted at the
> end of the table. I have created a listener object in the JTable
> which catches a keyEvent and if it is a ENTER key event, inserts a
> row at the end of the table. I am wondering whether this is the right
> way to go about it or is there a better way?
>
> /**
> * As each key is passed to the editor component in editCellAt()
> the keylistener
> * implemented in this class is notified.
> */
> public class ReturnKeyListener extends KeyAdapter{
>
> /**
> * This method checks whether the key is a RETURN/ENTER key and
> if it is,
> * the current edit is stopped by invoking the editors
> stopCellEditing() method.
> * If this works, the editor has been removed and the current
> row count is gotten
> * and if the editing row is the last row in the table, insertRow
> () is called.
> */
> public void keyPressed(KeyEvent evt){
> if(evt.getKeyCode() == KeyEvent.VK_ENTER){
> if(inReturnEditor == true){
> TableCellEditor editor =
> getCellEditor();
> int editRow = getEditingRow();
> int editCol = getEditingColumn();
> if (editor != null){
> boolean stopped =
> editor.stopCellEditing();
> if(stopped == true){
> int rowCount =
> getRowCount();
> if(editRow ==
> (rowCount - 1)){
> insertRow
> (editRow + 1);
> }
> }
> }
> }
> }
> }
> }
>
> I have come across some stuff about the TAB key and how Swing
> components filter out TAB key presses at a very low level and pass
> them to the Swing focus manager, where they are consumed(Core Swing
> advanced Programming:kim Topley). Is is the same for RETURN key
> presses.
>
> I have a second question : I want to validate the data entered into a
> textfield in a cell in the JTable and at the moment I am doing the
> validation in StopCellEditing(), is there a better way to do this?
>
> Thanks in advance
> Sinead
>
> --__--__--
>
> Message: 8
> Date: Wed, 28 Mar 2001 06:49:26 -0000
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Read the DefaultMutableTreeNode(applet) and write to file
>
> HI all,
> may I know how to search the whole tree and write it as a file?
> for example, my tree is like this,
>
> a
> b
> c
> -->c.1
> -->c.2
> ---->c.2.1
> ---->c.2.2
> d
> e
>
> I need to write it to a text file like this,
>
> 1) a
> 2) b
> 3) c
> c.1
> c.2
> c.2.1
> c.2.2
> 4) d
> 5) e
>
> thanks.
>
> --__--__--
>
> _______________________________________________
> Swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/swing
>
> End of Swing Digest
begin:vcard
n:Schaps;Gary L.
tel;cell:510.332.1814
tel;fax:510.623.2561
tel;work:510.623.5160
x-mozilla-html:FALSE
url:www.credence.com/people/garys
org:Credence Systems;Memory Products Division
adr:;;215 Fourier Ave.;Fremont;CA;94539;USA
version:2.1
email;internet:[EMAIL PROTECTED]
title:Principal Software Engineer
fn:Gary Schaps
end:vcard