This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
Can I have listener on the table header?
Samuel Chan
Greenhorn
Joined: Jun 10, 2001
Posts: 20
posted
Jun 28, 2001 02:23:00
0
I want to have some event when the user click on the table header.
Any idea?
Thanks.
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
Jun 28, 2001 05:55:00
0
Hi Samuel,
Yes, some idea. Replace MouseMotion with MouseClicked and you have a great example.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class JTableHeaderListener extends Frame { private JTable table; private DefaultTableModel dtm; public JTableHeaderListener() { setSize( 500, 500 ); dtm = new DefaultTableModel( 5, 5 ); table = new JTable( dtm ); JScrollPane sp = new JScrollPane( table ); add( sp, BorderLayout.CENTER ); table.getTableHeader().addMouseMotionListener( new MouseMotionAdapter() { public void mouseMoved( MouseEvent me ) { JTableHeader hdr = (JTableHeader)me.getSource(); hdr.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } }); } public static void main(String[] args) { JTableHeaderListener jhl = new JTableHeaderListener(); jhl.setVisible( true ); } }
Enjoy,
Manfred.
I agree. Here's the link:
http://aspose.com/file-tools
subject: Can I have listener on the table header?
Similar Threads
URGENT-Change cell width
Table header renderer
Wants Header of a JTable to be static.
Regarding Display Tag
how to delete a row header
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter