Skip to main content

FocusListener on header in JTable

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
douglasalipio
Offline
Joined: 2012-11-08
Points: 0

This does not work. How do I run this event?

public void mouseClicked(MouseEvent evt) {

table = ((JTableHeader) evt.getSource()).getTable();

table.getTableHeader.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(FocusEvent e) {
                System.out.println("focus");
            }

            @Override
            public void focusLost(FocusEvent e) {
     
                System.out.println("lost");
            }
});
}