Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Can I have listener on the table header?
Samuel Chan
Greenhorn
Posts: 20
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I want to have some event when the user click on the table header.
Any idea?
Thanks.
Manfred Leonhardt
Ranch Hand
Posts: 1492
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regarding Display Tag
how to delete a row header
Wants Header of a JTable to be static.
URGENT-Change cell width
Table header renderer
More...