List of usage examples for javax.swing JTable getColumnModel
public TableColumnModel getColumnModel()
From source file:org.omegat.gui.align.AlignPanelController.java
private static void resizeRows(JTable table) { for (int row = 0; row < table.getRowCount(); row++) { int max = 0; for (int col = BeadTableModel.COL_SRC; col < table.getColumnCount(); col++) { int colWidth = table.getColumnModel().getColumn(col).getWidth(); TableCellRenderer cellRenderer = table.getCellRenderer(row, col); Component c = table.prepareRenderer(cellRenderer, row, col); c.setBounds(0, 0, colWidth, Integer.MAX_VALUE); int height = c.getPreferredSize().height; max = Math.max(max, height); }//ww w . jav a 2 s . c om table.setRowHeight(row, max); } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement.java
public JTable creerJTable(ClasseCompte ccTmp) { final AssociationAnalytiqueModel model = new AssociationAnalytiqueModel(ccTmp); final JTable table = new JTable(model); final Vector vect = model.getRepartitionsAxe(); table.getColumnModel().getColumn(0).setCellRenderer(new PlanComptableCellRenderer(0)); table.getColumnModel().getColumn(1).setCellRenderer(new PlanComptableCellRenderer(0)); for (int i = 0; i < vect.size(); i++) { final Vector rep = (Vector) vect.get(i); JComboBox combo = new JComboBox(); for (int j = 0; j < rep.size(); j++) { combo.addItem(rep.get(j));// w ww . j av a 2 s. c om } table.getColumnModel().getColumn(i + 2).setCellEditor(new DefaultCellEditor(combo)); table.getColumnModel().getColumn(i + 2).setCellRenderer(new PlanComptableCellRenderer(0)); } table.getTableHeader().setReorderingAllowed(false); return table; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
/** * Cree un JTable contenant les ecritures du compte pass en argument * /*from w ww . j a v a 2s . c o m*/ * @param compte * @return null si aucune ecriture */ private JTable createJTableCompte(Compte compte) { // on cree la JTable final JTable tableTmp = creerJTable(compte); if (tableTmp != null) { // On met en place le renderer EcritureGrandLivreRenderer ecritureRenderer = new EcritureGrandLivreRenderer( ((TableSorter) tableTmp.getModel())); for (int j = 0; j < tableTmp.getColumnCount(); j++) { tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer); } // Gestion de la souris sur la JTable tableTmp.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent mE) { if (mE.getButton() == MouseEvent.BUTTON3) { JPopupMenu menuDroit = new JPopupMenu(); menuDroit.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { int row = tableTmp.rowAtPoint(mE.getPoint()); TableSorter s = (TableSorter) tableTmp.getModel(); int modelIndex = s.modelIndex(row); ConsultCompteModel consultCompteModel = ((ConsultCompteModel) s.getTableModel()); Ecriture ecriture = consultCompteModel.getEcritures().get(modelIndex); MouvementSQLElement.showSource(ecriture.getIdMvt()); } }); menuDroit.show(mE.getComponent(), mE.getX(), mE.getY()); } } }); } return tableTmp; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.PlanComptableGPanel.java
public JTable creerJTable(ClasseCompte ccTmp) { // NO_UCD final PlanComptableGModel model; if (this.radioCompteDeveloppe.isSelected()) { model = new PlanComptableGModel(ccTmp, 3); } else if (this.radioCompteAbrege.isSelected()) { model = new PlanComptableGModel(ccTmp, 2); } else {/*from w ww .j a v a 2 s . c om*/ model = new PlanComptableGModel(ccTmp, 1); } final JTable table = new JTable(model) { public JToolTip createToolTip() { JMultiLineToolTip t = new JMultiLineToolTip(); t.setFixedWidth(500); return t; } }; table.getColumnModel().getColumn(0).setCellRenderer(new PlanComptableCellRenderer(0)); table.getColumnModel().getColumn(1).setCellRenderer(new PlanComptableCellRenderer(0)); // TODO calcul de la taille de la colone numero de compte table.getColumnModel().getColumn(0).setMaxWidth(90); table.getTableHeader().setReorderingAllowed(false); table.addMouseMotionListener(new MouseMotionAdapter() { int lastRow = -1; public void mouseMoved(final MouseEvent e) { final Point p = new Point(e.getX(), e.getY()); SwingUtilities.invokeLater(new Runnable() { public void run() { final int row = table.rowAtPoint(p); if (lastRow != row) { lastRow = row; String strTmp = ((Compte) (model.getComptes().get(lastRow))).getInfos(); if (strTmp.length() != 0) { table.setToolTipText(strTmp); } else { table.setToolTipText(null); } } } }); } }); if (this.actionClickDroit != null) { // System.out.println("Ajout menu droit"); table.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { actionDroitTable(e, table); } } }); } // Enable row selection (default) /** * table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true); * * table.setSelectionMode(table.getSelectionModel().MULTIPLE_INTERVAL_SELECTION); */ table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = table.getSelectedRow(); if (selectedRow < 0) { // Pas de selection textInfos.setText("Pas de compte slctionn"); } else { textInfos.setText(((Compte) (model.getComptes().get(selectedRow))).getInfos()); } } }); return table; }
From source file:org.openstreetmap.josm.gui.preferences.imagery.CacheContentsPanel.java
private static JTable getTableForCache(final CacheAccess<String, BufferedImageCacheEntry> cache, final TableModel tableModel) { final JTable ret = new JTable(tableModel); ButtonColumn buttonColumn = new ButtonColumn(new AbstractAction() { @Override//from w w w. j ava 2s.c o m public void actionPerformed(ActionEvent e) { int row = ret.convertRowIndexToModel(ret.getEditingRow()); tableModel.setValueAt("0", row, 1); cache.remove(ret.getValueAt(row, 0).toString() + ':'); } }); TableColumn tableColumn = ret.getColumnModel().getColumn(2); tableColumn.setCellRenderer(buttonColumn); tableColumn.setCellEditor(buttonColumn); return ret; }
From source file:org.processmining.analysis.performance.dottedchart.ui.MetricsPanel.java
/** * Displays the performance metrics of each pattern on the east side of the * plug-in window.//ww w.j a v a2s . c o m * * @param sortedArray * int[] */ public void displayPerformanceMetrics() { String type = dcPanel.getTimeOption(); ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics(); ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles(); ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList(); this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // add time option menu this.add(Box.createRigidArea(new Dimension(5, 10))); JPanel menuPanel = new JPanel(new BorderLayout()); menuPanel.setPreferredSize(new Dimension(160, 45)); menuPanel.setMaximumSize(new Dimension(180, 45)); timeSortLabel.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(timeSortLabel, BorderLayout.NORTH); timeBox.setMaximumSize(new Dimension(160, 20)); timeBox.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(Box.createRigidArea(new Dimension(5, 0))); menuPanel.add(timeBox, BorderLayout.CENTER); this.add(menuPanel); this.add(Box.createRigidArea(new Dimension(5, 10))); // for each frequency get the set of patterns that have that frequency // (run from high frequency to low) int size = 0; for (int i = 0; i < aList.size(); i++) { try { String key; DescriptiveStatistics currentDS = null; if (i != 0) key = sortedTitleList.get(i - 1); else { key = aTitles.get(0); currentDS = aList.get(i); } if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; size++; if (i > 0) { for (int j = 1; j < aTitles.size(); j++) { if (aTitles.get(j).equals(key)) currentDS = aList.get(j); } } AbstractTableModel otm; // create labels that contains information about the pattern if (i == 0) otm = new OverallMetricTableModel(); else otm = new OneMetricTableModel(); DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer(); dtcr.setBackground(new Color(235, 235, 235)); JTable table = new JTable(otm); table.setPreferredSize(new Dimension(200, 55)); table.setMaximumSize(new Dimension(200, 55)); table.getColumnModel().getColumn(0).setPreferredWidth(70); table.getColumnModel().getColumn(0).setMaxWidth(100); table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12)); table.getColumnModel().getColumn(0).setCellRenderer(dtcr); table.setBorder(BorderFactory.createEtchedBorder()); // place throughput times in table if (type.equals(DottedChartPanel.TIME_ACTUAL)) { if (i == 0) { table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) { if (i == 0) { table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) { if (i == 0) { table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_LOGICAL) || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) { if (i == 0) { table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1); table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1); } else { table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1); table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1); } table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1); table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1); table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1); } JPanel tempPanel = new JPanel(new BorderLayout()); table.setAlignmentX(CENTER_ALIGNMENT); tempPanel.setPreferredSize(new Dimension(160, 98)); tempPanel.setMaximumSize(new Dimension(180, 98)); tempPanel.add(table.getTableHeader(), BorderLayout.NORTH); tempPanel.add(table, BorderLayout.CENTER); JPanel tempPanel2 = new JPanel(new BorderLayout()); JLabel patternLabel = new JLabel("Component " + key + ":"); patternLabel.setAlignmentX(LEFT_ALIGNMENT); JLabel frequencyLabel = null; if (i == 0) frequencyLabel = new JLabel("# of components: " + currentDS.getN()); else frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key)); frequencyLabel.setAlignmentX(LEFT_ALIGNMENT); frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12)); tempPanel2.add(patternLabel, BorderLayout.NORTH); tempPanel2.add(frequencyLabel, BorderLayout.CENTER); tempPanel2.add(tempPanel, BorderLayout.SOUTH); this.add(tempPanel2); this.add(Box.createRigidArea(new Dimension(5, 10))); } catch (NullPointerException ex) { // can occur when patternMap does not contain a pattern with // this frequency size--; } } // make sure the pattern performance information is displayed properly this.setPreferredSize(new Dimension(200, 140 * (size + 1))); this.revalidate(); this.repaint(); }
From source file:org.prom5.analysis.performance.dottedchart.ui.MetricsPanel.java
/** * Displays the performance metrics of each pattern on the east side of the * plug-in window.// w ww .j a v a2s . c o m * @param sortedArray int[] */ public void displayPerformanceMetrics() { String type = dcPanel.getTimeOption(); ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics(); ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles(); ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList(); this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //add time option menu this.add(Box.createRigidArea(new Dimension(5, 10))); JPanel menuPanel = new JPanel(new BorderLayout()); menuPanel.setPreferredSize(new Dimension(160, 45)); menuPanel.setMaximumSize(new Dimension(180, 45)); timeSortLabel.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(timeSortLabel, BorderLayout.NORTH); timeBox.setMaximumSize(new Dimension(160, 20)); timeBox.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(Box.createRigidArea(new Dimension(5, 0))); menuPanel.add(timeBox, BorderLayout.CENTER); this.add(menuPanel); this.add(Box.createRigidArea(new Dimension(5, 10))); //for each frequency get the set of patterns that have that frequency //(run from high frequency to low) int size = 0; for (int i = 0; i < aList.size(); i++) { try { String key; DescriptiveStatistics currentDS = null; if (i != 0) key = sortedTitleList.get(i - 1); else { key = aTitles.get(0); currentDS = aList.get(i); } if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; size++; if (i > 0) { for (int j = 1; j < aTitles.size(); j++) { if (aTitles.get(j).equals(key)) currentDS = aList.get(j); } } AbstractTableModel otm; //create labels that contains information about the pattern if (i == 0) otm = new OverallMetricTableModel(); else otm = new OneMetricTableModel(); DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer(); dtcr.setBackground(new Color(235, 235, 235)); JTable table = new JTable(otm); table.setPreferredSize(new Dimension(200, 55)); table.setMaximumSize(new Dimension(200, 55)); table.getColumnModel().getColumn(0).setPreferredWidth(70); table.getColumnModel().getColumn(0).setMaxWidth(100); table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12)); table.getColumnModel().getColumn(0).setCellRenderer(dtcr); table.setBorder(BorderFactory.createEtchedBorder()); //place throughput times in table if (type.equals(DottedChartPanel.TIME_ACTUAL)) { if (i == 0) { table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) { if (i == 0) { table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) { if (i == 0) { table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_LOGICAL) || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) { if (i == 0) { table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1); table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1); } else { table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1); table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1); } table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1); table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1); table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1); } JPanel tempPanel = new JPanel(new BorderLayout()); table.setAlignmentX(CENTER_ALIGNMENT); tempPanel.setPreferredSize(new Dimension(160, 98)); tempPanel.setMaximumSize(new Dimension(180, 98)); tempPanel.add(table.getTableHeader(), BorderLayout.NORTH); tempPanel.add(table, BorderLayout.CENTER); JPanel tempPanel2 = new JPanel(new BorderLayout()); JLabel patternLabel = new JLabel("Component " + key + ":"); patternLabel.setAlignmentX(LEFT_ALIGNMENT); JLabel frequencyLabel = null; if (i == 0) frequencyLabel = new JLabel("# of components: " + currentDS.getN()); else frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key)); frequencyLabel.setAlignmentX(LEFT_ALIGNMENT); frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12)); tempPanel2.add(patternLabel, BorderLayout.NORTH); tempPanel2.add(frequencyLabel, BorderLayout.CENTER); tempPanel2.add(tempPanel, BorderLayout.SOUTH); this.add(tempPanel2); this.add(Box.createRigidArea(new Dimension(5, 10))); } catch (NullPointerException ex) { //can occur when patternMap does not contain a pattern with this frequency size--; } } //make sure the pattern performance information is displayed properly this.setPreferredSize(new Dimension(200, 140 * (size + 1))); this.revalidate(); this.repaint(); }
From source file:org.svv.acmate.gui.ACTestingPanel.java
private void resizeColumnWidth(JTable table) { final TableColumnModel columnModel = table.getColumnModel(); for (int column = 0; column < table.getColumnCount(); column++) { int width = 80; // Min width for (int row = 0; row < table.getRowCount(); row++) { TableCellRenderer renderer = table.getCellRenderer(row, column); Component comp = table.prepareRenderer(renderer, row, column); width = Math.max(comp.getPreferredSize().width + 1, width); }/*from w ww . java2 s.co m*/ columnModel.getColumn(column).setPreferredWidth(width); } }
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java
private void setupTable() { tableModel = new ElementListTableModel(); table = new JXTable(tableModel); tableSorter = new ElementListTableSorter(tableModel, table); table.getTableHeader().addMouseListener(tableSorter); // add sorter & header renderer table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true);/*from w w w . j a v a 2s .c o m*/ // set our column widths ElementListTableModel.setupColumnWidths(table); table.setDefaultRenderer(Object.class, new ElementListCellRenderer(this, false)); table.setDefaultRenderer(Boolean.class, new BooleanCellRenderer(this, false)); // hide irrelevent columns TableColumnModelExt colmodel = (TableColumnModelExt) table.getColumnModel(); table.setColumnControlVisible(true); colmodel.getColumnExt(I18n.getText("hidden.MostRecentVersion")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.n")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.rec")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.hash")).setVisible(false); // popup menu table.addMouseListener(new PopupListener() { @Override public void showPopup(MouseEvent e) { // only clicks on tables if (!(e.getSource() instanceof JTable)) return; JTable table = (JTable) e.getSource(); ElementListTableModel model = (ElementListTableModel) table.getModel(); // get the row and sanity check int row = table.rowAtPoint(e.getPoint()); if (row < 0 || row >= model.getRowCount()) return; // select it? table.setRowSelectionInterval(row, row); // get the element Element element = model.getElementAt(row); // create and show the menu JPopupMenu popup = new ElementListPopupMenu(element, ComponentViewer.this); popup.show(table, e.getX(), e.getY()); } }); }
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java
private void setupTable() { tableModel = new ElementListTableModel(); table = new JXTable(tableModel); tableSorter = new ElementListTableSorter(tableModel, table); table.getTableHeader().addMouseListener(tableSorter); // add sorter & header renderer table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true);//from w w w. j a v a 2 s .co m // set our column widths ElementListTableModel.setupColumnWidths(table); table.setDefaultRenderer(Object.class, new ElementListCellRenderer(this, false)); table.setDefaultRenderer(Boolean.class, new BooleanCellRenderer(this, false)); // hide irrelevent columns TableColumnModelExt colmodel = (TableColumnModelExt) table.getColumnModel(); table.setColumnControlVisible(true); colmodel.getColumnExt(I18n.getText("hidden.MostRecentVersion")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.n")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.rec")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.hash")).setVisible(false); // popup menu table.addMouseListener(new PopupListener() { @Override public void showPopup(MouseEvent e) { // only clicks on tables if (!(e.getSource() instanceof JTable)) return; JTable table = (JTable) e.getSource(); ElementListTableModel model = (ElementListTableModel) table.getModel(); // get the row and sanity check int row = table.rowAtPoint(e.getPoint()); if (row < 0 || row >= model.getRowCount()) return; // select it? table.setRowSelectionInterval(row, row); // get the element Element element = model.getElementAt(row); // create and show the menu JPopupMenu popup = new ElementListPopupMenu(element, ComponentViewerOld.this); popup.show(table, e.getX(), e.getY()); } }); }