I want to set the focus on JTable with no rows. Generally when any component receives the focus I set a blue border around the component. The same thing I want to apply for JTable. By pressing the tab button i.e by doing focus traversal, when JTable with no rows receives the focus then blue border is set around the JTable. However when I explictly click on JTable with no rows then the blue border is not drawn. What I observed is when I added focus listener and mouse listener to JTable, even the call back methods werent called when I click on JTable with no rows. Can anyone help how can I set the blue border on JTable with no rows.
even the call back methods werent called The table consumes mouse and focus events because it has (behind the scenes) MouseListeners that are listening for user selections and FocusListeners that are listening for focus changes. Can anyone help... Add a MouseListener to the JTable and listen for mouse events in the mouseClicked method to set your blue border. Adding your own listeners is an accepted way of customizing JTable to your needs.