Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2004

Tip: Looking for answers? Try searching our database.

How to define a JTableHeader

Thread view: 
LuKe - 29 Aug 2004 18:36 GMT
Hi,

I want to define a new JTableHeader but I don't have any idea how to do
that.

I would like to get the current JTableHeader from the JTable, get the
name of each Column and then set the new column names.

How can I do that?

Thanks

LuKe
Nick Pomfret - 30 Aug 2004 11:25 GMT
There are a few ways to do this.  I would recommend creating your JTable
with a TableColumnModel and setting the necessary values in your column
model:

       TableColumnModel columnModel = new DefaultTableColumnModel();
       TableColumn column = new TableColumn();
       column.setHeaderValue("my first column");
       columnModel.addColumn(column);

       TableModel tableModel = new DefaultTableModel();
       tableModel.setValueAt("hello", 0, 0);
       tableModel.setValueAt("world", 1, 0);

       JTable table = new JTable(tableModel, columnModel);

However, if you need to change the value in the column heading at runtime
you might use:

       table.getColumnModel().getColumn(0).setHeaderValue("my renamed
column");

Signature

** http://www.tabletoolkit.com **
Aggregate a JTable to an arbitrary level to create your own pivot tables

> Hi,
>
[quoted text clipped - 9 lines]
>
> LuKe


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.