For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2004 > Table Header









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Table Header
Goran

2004-03-30, 6:37 am

How can I change border of table header.

Thanks in advance
--
To reply please remove NOSPAM

Karl von Laudermann

2004-03-30, 12:44 pm

Goran <goran021@neobee.net_NOSPAM> wrote in message news:<c4bk0r$7vk$1@shiva.neobee.net>...
> How can I change border of table header.


Create a subclass of DefaultTableCellRenderer. Override the method
getTableCellRendererComponent() to call the superclass version. Cast
its return value to JLabel and call setBorder() on it before returning
it yourself, to set the desired border. (See the API docs for the
Border interface to learn how to set a border).

Then you must set the table to use your custom renderer to render
table header cells. Assuming that your renderer subclass is called
MyHeaderCellRenderer, and your JTable instance is in a variable called
myTable, do this:

myTable.getTableHeader().setDefaultRenderer(new
MyHeaderCellRenderer());
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com