public void setColumnDefinitions(ColumnDisplayDefinition[] colDefs) { TableColumnModel tcm = createColumnModel(colDefs); setColumnModel(tcm); _typedModel.setHeadings(colDefs); // just in case table is editable, call creator to set up cell editors _creator.setCellEditors(this); _tablePopupMenu.reset(); }
private void createGUI( boolean allowUpdate, IDataSetUpdateableModel updateableObject, int selectionMode, ISession session) { setSelectionMode(selectionMode); setRowSelectionAllowed(false); setColumnSelectionAllowed(false); setCellSelectionEnabled(true); getTableHeader().setResizingAllowed(true); getTableHeader().setReorderingAllowed(true); setAutoCreateColumnsFromModel(false); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); setTableHeader(_tableHeader); _tableHeader.setTable(this); _tablePopupMenu = new TablePopupMenu( allowUpdate, updateableObject, DataSetViewerTablePanel.this, getDataModelImplementationDetails(), session); _tablePopupMenu.setTable(this); addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { onMousePressed(evt, false); } public void mouseReleased(MouseEvent evt) { onMouseReleased(evt); } }); getTableHeader() .addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { onMousePressed(evt, true); } public void mouseReleased(MouseEvent evt) { onMouseReleased(evt); } }); }
/** Display the popup menu for this component. */ private void displayPopupMenu(MouseEvent evt) { _tablePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); }