🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11483

Re: Colouring rows in JTable

#11483
From: Brian Duff
Date: Tue, 25 May 1999 00:00
23 lines
1543 bytes
Peter Hawkins <Peter.Hawkins@hos.horizon.ie> wrote in message
news:374A7137.B77EB648@hos.horizon.ie...
> Hi,
>
> Is there an easy way to colour the rows in a JTable. What I would like
> is say, the odd rows to be background white while the even rows are
> background blue, to aid the user in examining a large table.


Have a look at the API for javax.swing.table.DefaultTableCellRenderer. You
probably want to subclass DefaultTableCellRenderer and set the background
color depending on the row number. Then just use JTable.setCellRenderer(...)
to use your customized renderer.

Brian

-----------------------------------------------------------------------
Brian Duff,Software Engineer,JDeveloper Enterprise Ed. 3.0 Development
The views expressed here don't necessarily represent those of Oracle

Work: bduff@uk.oracle.com        Play: dubh@btinternet.com
Tel: (+44) (0)1189 244901        http://wired.dcs.st-and.ac.uk/~briand
-----------------------------------------------------------------------
Technical Details
Message-ID: <7if9j0$juu$1@plutonium.btinternet.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <374A7137.B77EB648@hos.horizon.ie>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c4ba3c7ea82e452c
X-Google-Attributes: gid111d45,public
From: "Brian Duff" <dubh@btinternet.com>
Subject: Re: Colouring rows in JTable
Date: 1999/05/25
Message-ID: <7if9j0$juu$1@plutonium.btinternet.com>
X-Deja-AN: 482088517
References: <374A7137.B77EB648@hos.horizon.ie>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Organization: BT Internet
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing