Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order of listeners in Java

I wrote my own table cell editor that extends an AbstractCellEditor and implements a TableCellEditor, an ItemListener, and a MouseListener. Is there a way I can have the mouseClicked method be executed first before the itemStateChanged method? I'm trying to do the following:

private int rowClicked;
private JTable table;

public void itemStateChanged(ItemEvent e) {
  if (rowClicked == 5) {
    // Do something to row 5.
  }
}

public void mouseClicked(MouseEvent e) {
  Point p = e.getPoint();
  rowClicked = table.rowAtPoint(p);
}
like image 838
BJ Dela Cruz Avatar asked Sep 30 '11 16:09

BJ Dela Cruz


1 Answers

Here is a nice article explaining the absence of listener notification order in swing: Swing in a better world

like image 115
Fredrik LS Avatar answered Oct 05 '22 23:10

Fredrik LS