wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes can i set an event for jtable header? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can i set an event for jtable header?" Watch "can i set an event for jtable header?" New topic
Author

can i set an event for jtable header?

phooton misra
Ranch Hand

Joined: Jul 31, 2012
Posts: 40

Somebody please suggest me ,

can i set an event for jtable header?[color=green][/color][size=18][/size]
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2176
    
  47
What sort of event are you wanting to set up? ie what are you trying to achieve?
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
you can to add XxxCellRenderer to the JTableHeader, inc. MouseListener , there are a few ways how to ...
phooton misra
Ranch Hand

Joined: Jul 31, 2012
Posts: 40

hi tony

In my table there is an alternative background colors for the rows and after sorting the background color should be cahnged with change of rows ?

suppose

row 1 green

row2 yellow

row 3 red

and after sorting it should be

row 3 red

row 2 yellow

row 1 green

but it is coming like this

row 3 green

row 2 yellow

row 1 red.
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
- JTable can be sorted or filtered, JTable Columns can be reordered,

- then have to convert indexes betweens JTables view to the XxxTableModel or vice versa

- put and implements indexing inside XxxXxxRenderer



- for better help sooner post an (short, runnable, compilable) SSCCE, demonstrating your issue
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can i set an event for jtable header?
 
Similar Threads
jtable
JTable Columns
Can we set an image in a cell of a jtable.
JTable
Disabling the JTable