before you go any further, dump mouseClicked() - it doesn't always fire.
run this demo, click anywhere on the panel, and you should see this printed out
pressed
released
clicked
note the order
now press and hold the left mouse button (anywhere), drag the mouse a few pixels left right up or down,
now release the left mouse button, and you'll notice mouseClicked() will not fire.
Micheal is correct in saying the mouseClicked event doesn't always fire but there good reasons for that, ie a mouse click is generally considered to have occurred when the user has pressed and released the mouse button (or pressed and released a touch screen etc) within 'n' pixels of each other within the same component.
Be careful before ditching mouseClicked, there are potential problems with just using mousePressed or mouseReleased. For example if using just mousePressed you can't drag the mouse over several cells of a JTable to highlight multiple cells, users can be surprised when something happens before they have released the mouse button etc. If using just mouseReleased does the user really want the program respond to the event if say they have pressed the mouse button on another component, decided they didn't want to click there so moved the mouse over the JTable and released the button.
From glancing through the 135 lines of code, it rather looks like you want to respond to a selection change. If that's so, a MouseListener is not the appropriate listener; use a ListSelectionListener instead.
luck, db
There are no new questions, but there may be new answers.
Tony Docherty wrote:If using just mouseReleased does the user really want the program respond to the event if say they have pressed the mouse button on another component, decided they didn't want to click there so moved the mouse over the JTable and released the button.
That doesn't trigger a MouseListener added to the table. mouseReleased events are generated for the component over which the mouse was pressed.
luck, db
There are no new questions, but there may be new answers.
Tony Docherty wrote:If using just mouseReleased does the user really want the program respond to the event if say they have pressed the mouse button on another component, decided they didn't want to click there so moved the mouse over the JTable and released the button.
That doesn't trigger a MouseListener added to the table. mouseReleased events are generated for the component over which the mouse was pressed.
Good point. Yes that part of my statement was wrong.
Although the essence of what I was saying still applies, in that by checking for mouseReleased rather than mouseClicked if the mouse is dragged away from the component an event will be handled that the user possibly wouldn't expect.