🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Newbie - Help on JTable Display

#10056
From: John P. McGrath
Date: Mon, 29 Nov 1999 00:00
35 lines
1782 bytes
On Thu, 25 Nov 1999 11:30:18 +0530, Guest wrote:

> I am new to using Java/JFC. I have to use Jtable component and provide a
> display as follows...
> 
> Col A|     Col B            | Col C |
>           | Col B1 |Col B2|           |
> --------------------------------
>           |             |           |           |
> --------------------------------
> 
> Pls advice and help.

You will have to write a TableCellRenderer to display the column headers, 
then use the TableColumn setHeaderRenderer() method to set the header 
renderer for the columns.  You can get the TableColumn object for the 
column you want using the JTable getColumn() method.

Writing this will not be trivial -- you will need to draw one half of the 
combined header when drawing the header for column B1, and the other half 
when drawing the column for B2.  I think you should create a separate 
renderer for the combined header, and then call it from the other 
renderers.  You may have to translate() the graphics object when you do 
this.

You also may need to deal with the possibility of column re-ordering if 
that is enabled.  Obviously, if another column were moved between columns 
B1 and B2, you would have a problem.

I hope this helps.

-- 
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.12abe52952dbc9b9896cd@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <383CD072.3FF9B1C5@hotmail.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,4d43e388b1d76d3a
X-Google-Attributes: gid111d45,public
From: John P. McGrath <mcgrath@enter.net>
Subject: Re: Newbie - Help on JTable Display
Date: 1999/11/29
Message-ID: <MPG.12abe52952dbc9b9896cd@forums.borland.com>
X-Deja-AN: 554311027
References: <383CD072.3FF9B1C5@hotmail.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing