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 / General / November 2005

Tip: Looking for answers? Try searching our database.

multiple line table headers

Thread view: 
Srikanth - 28 Nov 2005 06:30 GMT
 I have a table which is sortable. There is a column which shows
checkboxes.
  Now the requirement is - a Checkbox has to be added to the table
header so that when the checkbox is selected, all the checkboxes in
that column get selected and vice versa.
 But if i render the table header with checkbox, i cant add the sort
icon. So i am thinking of having a two line table header - first line
containing the table header text and sort icon, the second line
containing the checkbox.
 Can anyone please tell me how this can be done.
 Thanks in advance
NullBock - 28 Nov 2005 09:27 GMT
This is tricky, but is certainly possible.  We do this in several of
our applications, adding a text-box to allow for cell filtering on a
column-by-column basis.

Basically, you need to override each column's TableCellRenderer with
one of your own creation.  Any component can be returned from the
getTableCellRendererComponent; we return a JPanel containing the JLabel
(for the header) and a JTextBox (for the user input), layed out with a
GridBagLayout.

A tricky aspect of this is interpreting and passing-on mouse clicks.
With a checkbox, this shouldn't be too hard, since you only need to
pass on clicks, and needn't worry about replacing the components in the
header with editors, which we have to do with ours (the JTextBox
becomes a JComboBox when clicked).

To set the TabelCellRenderer, I've overriden the
JTable#addColumn(JTableColumn) method.  This works, but I'm sure there
are better ways of doing it.

Hope this helps,

Walter Gildersleeve
Freiburg, Germany

______________________________________________
http://linkfrog.net
URL Shortening
Free and easy, small and green


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.