Browse Source

Fixed bug where java 1.6 gave an exception when clicking on path table header.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@469 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Mark Kattenbelt 18 years ago
parent
commit
a5cd6a4b56
  1. 15
      prism/src/userinterface/util/GUIGroupedTable.java
  2. 14
      prism/src/userinterface/util/GUIGroupedTableHeader.java

15
prism/src/userinterface/util/GUIGroupedTable.java

@ -112,11 +112,18 @@ public class GUIGroupedTable extends JTable
@Override @Override
protected JTableHeader createDefaultTableHeader() { protected JTableHeader createDefaultTableHeader() {
GUIGroupedTableHeader header = null;
if (columnModel != null && columnModel instanceof GUIGroupedTableColumnModel) if (columnModel != null && columnModel instanceof GUIGroupedTableColumnModel)
{
return new GUIGroupedTableHeader((GUIGroupedTableColumnModel)columnModel, (GUIGroupedTableModel)this.getModel());
}
return new GUIGroupedTableHeader(new GUIGroupedTableColumnModel(), (GUIGroupedTableModel)this.getModel());
header = new GUIGroupedTableHeader((GUIGroupedTableColumnModel)columnModel, (GUIGroupedTableModel)this.getModel(), this);
else
header = new GUIGroupedTableHeader(new GUIGroupedTableColumnModel(), (GUIGroupedTableModel)this.getModel(), this);
header.setTable(this);
return header;
} }
} }

14
prism/src/userinterface/util/GUIGroupedTableHeader.java

@ -50,19 +50,20 @@ public class GUIGroupedTableHeader extends JTableHeader implements TableColumnMo
* Creates a new GUIGroupedTableHeader. * Creates a new GUIGroupedTableHeader.
* @param model The column model that is the basis of this table header (must be grouped). * @param model The column model that is the basis of this table header (must be grouped).
*/ */
public GUIGroupedTableHeader(GUIGroupedTableColumnModel model, GUIGroupedTableModel tableModel)
public GUIGroupedTableHeader(GUIGroupedTableColumnModel model, GUIGroupedTableModel tableModel, GUIGroupedTable table)
{ {
super(); super();
removeAll(); removeAll();
this.model = model; this.model = model;
this.tableModel = tableModel; this.tableModel = tableModel;
topHeader = new JTableHeader(model.getGroupTableColumnModel()); topHeader = new JTableHeader(model.getGroupTableColumnModel());
topHeader.setResizingAllowed(false); topHeader.setResizingAllowed(false);
topHeader.setReorderingAllowed(false); topHeader.setReorderingAllowed(false);
final TableCellRenderer renderer = topHeader.getDefaultRenderer(); final TableCellRenderer renderer = topHeader.getDefaultRenderer();
topHeader.setDefaultRenderer(new TableCellRenderer() { topHeader.setDefaultRenderer(new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
@ -75,7 +76,10 @@ public class GUIGroupedTableHeader extends JTableHeader implements TableColumnMo
bottomHeader = new JTableHeader(model); bottomHeader = new JTableHeader(model);
bottomHeader.setReorderingAllowed(false); bottomHeader.setReorderingAllowed(false);
topHeader.setTable(table);
bottomHeader.setTable(table);
setLayout(new GridLayout(2,1)); setLayout(new GridLayout(2,1));
add(topHeader); add(topHeader);
@ -119,7 +123,7 @@ public class GUIGroupedTableHeader extends JTableHeader implements TableColumnMo
}); });
bottomHeader.addMouseMotionListener(new MouseMotionAdapter() bottomHeader.addMouseMotionListener(new MouseMotionAdapter()
{ {
private TableColumn lastColumn;
private TableColumn lastColumn;
public void mouseMoved(MouseEvent e) public void mouseMoved(MouseEvent e)
{ {
@ -217,7 +221,7 @@ private TableColumn lastColumn;
* Overwritten to catch events of child components. * Overwritten to catch events of child components.
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
this.dispatchEvent(new MouseEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY() + ((Component)e.getSource()).getBounds().y, e.getClickCount(), e.isPopupTrigger()));
this.dispatchEvent(new MouseEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY() + ((Component)e.getSource()).getBounds().y, e.getClickCount(), e.isPopupTrigger()));
} }
/** /**

Loading…
Cancel
Save