Java Code Examples for javax.swing.table.TableColumn#setIdentifier()
The following examples show how to use
javax.swing.table.TableColumn#setIdentifier() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeapInformationsPanel.java From javamelody with Apache License 2.0 | 6 votes |
private MTableScrollPane<HeapHistogram.ClassInfo> createScrollPane(long totalInstances, long totalBytes, boolean sourceDisplayed) { final MTableScrollPane<HeapHistogram.ClassInfo> tableScrollPane = new MTableScrollPane<>(); final MTable<ClassInfo> myTable = tableScrollPane.getTable(); myTable.addColumn("name", getString("Classe")); myTable.addColumn("bytes", getString("Taille")); final TableColumn pctTailleColumn = new TableColumn(myTable.getColumnCount()); pctTailleColumn.setIdentifier(myTable.getColumnCount()); pctTailleColumn.setHeaderValue(getString("pct_taille")); myTable.addColumn(pctTailleColumn); myTable.addColumn("instancesCount", getString("Instances")); final TableColumn pctInstancesColumn = new TableColumn(myTable.getColumnCount()); pctInstancesColumn.setIdentifier(myTable.getColumnCount()); pctInstancesColumn.setHeaderValue(getString("pct_instances")); myTable.addColumn(pctInstancesColumn); if (sourceDisplayed) { myTable.addColumn("source", getString("Source")); } myTable.setColumnCellRenderer("bytes", new BytesTableCellRenderer()); pctTailleColumn.setCellRenderer(new PctTailleTableCellRenderer(totalBytes)); pctInstancesColumn.setCellRenderer(new PctInstancesTableCellRenderer(totalInstances)); return tableScrollPane; }
Example 2
Source File: MTable.java From javamelody with Apache License 2.0 | 6 votes |
/** * Ajoute une colonne dans la table. * * @param attribute * Nom de l'attribut des objets à afficher dans la colonne<br/> * @param libelle * Libellé à afficher en entête de la colonne * @return this (fluent) */ public MTable<T> addColumn(final String attribute, final String libelle) { final int modelIndex = getColumnCount(); final TableColumn tableColumn = new TableColumn(modelIndex); // on met l'énumération de l'attribut comme identifier dans le TableColumn pour s'en servir dans MTableModel tableColumn.setIdentifier(attribute); if (libelle == null) { // on prend par défaut l'attribut si le libellé n'est pas précisé, tableColumn.setHeaderValue(attribute); } else { // le libellé a été précisé pour l'entête de cette colonne tableColumn.setHeaderValue(libelle); } // ajoute la colonne dans la table super.addColumn(tableColumn); return this; }
Example 3
Source File: JPPFTreeTable.java From JPPF with Apache License 2.0 | 5 votes |
/** * Initialize this tree table with the specified model. * @param treeTableModel - a tree table model. */ public JPPFTreeTable(final AbstractJPPFTreeTableModel treeTableModel) { super(treeTableModel); for (int i = 0; i < treeTableModel.getColumnCount(); i++) { final TableColumn column = getColumnModel().getColumn(i); column.setIdentifier(Integer.valueOf(i)); } }
Example 4
Source File: CreateTableDialog.java From netbeans with Apache License 2.0 | 5 votes |
public DataTable(TableModel model) { super(model); setSurrendersFocusOnKeystroke(true); TableColumnModel cmodel = getColumnModel(); int i; int ccount = model.getColumnCount(); int columnWidth; int preferredWidth; String columnName; int width = 0; for (i = 0; i < ccount; i++) { TableColumn col = cmodel.getColumn(i); Map cmap = ColumnItem.getColumnProperty(i); col.setIdentifier(cmap.get("name")); //NOI18N columnName = NbBundle.getMessage (CreateTableDialog.class, "CreateTable_" + i); //NOI18N columnWidth = (new Double(getFontMetrics(getFont()).getStringBounds(columnName, getGraphics()).getWidth())).intValue() + 20; if (cmap.containsKey("width")) { // NOI18N if (((Integer)cmap.get("width")).intValue() < columnWidth) col.setPreferredWidth(columnWidth); else col.setPreferredWidth(((Integer)cmap.get("width")).intValue()); // NOI18N preferredWidth = col.getPreferredWidth(); } if (cmap.containsKey("minwidth")) // NOI18N if (((Integer)cmap.get("minwidth")).intValue() < columnWidth) col.setMinWidth(columnWidth); else col.setMinWidth(((Integer)cmap.get("minwidth")).intValue()); // NOI18N // if (cmap.containsKey("alignment")) {} // if (cmap.containsKey("tip")) ((JComponent)col.getCellRenderer()).setToolTipText((String)cmap.get("tip")); if (i < 7) { // the first 7 columns should be visible width += col.getPreferredWidth(); } } width = Math.min(Math.max(width, 380), Toolkit.getDefaultToolkit().getScreenSize().width - 100); setPreferredScrollableViewportSize(new Dimension(width, 150)); }
Example 5
Source File: DesktopAbstractTable.java From cuba with Apache License 2.0 | 5 votes |
protected void setColumnIdentifiers() { int i = 0; for (TableColumn tableColumn : getAllColumns()) { Column column = columnsOrder.get(i++); if (!(tableColumn.getIdentifier() instanceof Column)) { tableColumn.setIdentifier(column); } } }
Example 6
Source File: SorterTableColumnModel.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private TableColumn makeTableColumn(int x, Sortables c) { TableColumn tc = new TableColumn(x); FBTableCellRenderer temp = new FBTableCellRenderer(); tc.setHeaderRenderer(temp); tc.setIdentifier(c); tc.setHeaderValue(c); tc.setResizable(false); tc.sizeWidthToFit(); return tc; }
Example 7
Source File: NamedIrSignal.java From IrScrutinizer with GNU General Public License v3.0 | 5 votes |
private void setup() { for (int i = 0; i < columnFunc.noFields(); i++) { TableColumn column = new TableColumn(i, columnFunc.width(i)); column.setHeaderValue(columnFunc.name(i)); column.setIdentifier(i); addColumn(column); } }
Example 8
Source File: DependenciesPanel.java From javamelody with Apache License 2.0 | 5 votes |
private MTableScrollPane<String> createScrollPane() { final MTableScrollPane<String> tableScrollPane = new MTableScrollPane<>(); final MTable<String> myTable = tableScrollPane.getTable(); final TableColumn artifactTableColumn = new TableColumn(myTable.getColumnCount()); artifactTableColumn.setIdentifier(myTable.getColumnCount()); artifactTableColumn.setHeaderValue("Artifact"); artifactTableColumn.setCellRenderer(new MDefaultTableCellRenderer()); myTable.addColumn(artifactTableColumn); final TableColumn nameTableColumn = new TableColumn(myTable.getColumnCount()); nameTableColumn.setIdentifier(myTable.getColumnCount()); nameTableColumn.setHeaderValue(getString("Nom")); nameTableColumn.setCellRenderer(new NameTableCellRenderer()); myTable.addColumn(nameTableColumn); final TableColumn mavenIdTableColumn = new TableColumn(myTable.getColumnCount()); mavenIdTableColumn.setIdentifier(myTable.getColumnCount()); mavenIdTableColumn.setHeaderValue("Maven Id"); mavenIdTableColumn.setCellRenderer(new MavenIdTableCellRenderer()); myTable.addColumn(mavenIdTableColumn); final TableColumn licenseTableColumn = new TableColumn(myTable.getColumnCount()); licenseTableColumn.setIdentifier(myTable.getColumnCount()); licenseTableColumn.setHeaderValue(getString("Licence")); licenseTableColumn.setCellRenderer(new LicenseTableCellRenderer()); myTable.addColumn(licenseTableColumn); myTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { actionOpenUrl(); } } }); return tableScrollPane; }
Example 9
Source File: CounterRequestForContextTable.java From javamelody with Apache License 2.0 | 5 votes |
private void addCustomColumn(String headerValue, TableCellRenderer tableCellRenderer) { final TableColumn tableColumn = new TableColumn(getColumnCount()); tableColumn.setIdentifier(getColumnCount()); tableColumn.setHeaderValue(headerValue); tableColumn.setCellRenderer(tableCellRenderer); addColumn(tableColumn); }
Example 10
Source File: WebFileTable.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Updates column preferred sizes. */ private void updateColumnSizes () { for ( int i = 0; i < getColumnCount (); i++ ) { final WebFileTableModel model = getFileTableModel (); final TableColumn column = getColumnModel ().getColumn ( i ); column.setIdentifier ( model.getColumnId ( i ) ); if ( model.getColumnId ( i ).equals ( NUMBER_COLUMN ) ) { column.setPreferredWidth ( 30 ); } else if ( model.getColumnId ( i ).equals ( NAME_COLUMN ) ) { column.setPreferredWidth ( 340 ); } else if ( model.getColumnId ( i ).equals ( SIZE_COLUMN ) || model.getColumnId ( i ).equals ( EXTENSION_COLUMN ) ) { column.setPreferredWidth ( 90 ); } else if ( model.getColumnId ( i ).equals ( CREATION_DATE_COLUMN ) || model.getColumnId ( i ).equals ( MODIFICATION_DATE_COLUMN ) ) { column.setPreferredWidth ( 130 ); } } }
Example 11
Source File: StatTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
public static void initializeTable(JTable statsTable) { JTableHeader tableHeader = statsTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); statsTable.setAutoCreateColumnsFromModel(false); DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); { TableColumn column = Utilities.createTableColumn(ABILITY_NAME, "Ability", new AbilityHeaderCellRenderer(), true); column.setIdentifier(ABILITY_COLUMN_ID); columnModel.addColumn(column); String htmlText = "<html><div align=\"center\">Final<br>Score</div></html>"; column = Utilities.createTableColumn(FINAL_ABILITY_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(new ValueRenderer()); columnModel.addColumn(column); TableCellRenderer renderer = new ModRenderer(); htmlText = "<html><div align=\"center\">Ability<br>Mod</div></html>"; column = Utilities.createTableColumn(ABILITY_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Editable<br>Score</div></html>"; column = Utilities.createTableColumn(EDITABLE_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setIdentifier(EDITABLE_COLUMN_ID); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Race<br>Adj</div></html>"; column = Utilities.createTableColumn(RACE_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Misc<br>Adj</div></html>"; column = Utilities.createTableColumn(MISC_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); } statsTable.setColumnModel(columnModel); statsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); statsTable.setShowVerticalLines(false); statsTable.setCellSelectionEnabled(false); statsTable.setFocusable(false); // XXX this should be calculated relative to font size and the size of a jspinner statsTable.setRowHeight(27); statsTable.setOpaque(false); tableHeader.setFont(FontManipulation.title(statsTable.getFont())); FontManipulation.large(statsTable); }
Example 12
Source File: CounterRequestDetailTablePanel.java From javamelody with Apache License 2.0 | 4 votes |
private MTableScrollPane<CounterRequest> createScrollPane() { final MTable<CounterRequest> table = getTable(); final MTableScrollPane<CounterRequest> tableScrollPane = new MTableScrollPane<>(table); table.addColumn("name", getString("Requete")); table.setColumnCellRenderer("name", new NameTableCellRenderer()); if (!childRequestsExecutions.isEmpty()) { final TableColumn nbExecutionsColumn = new TableColumn(table.getColumnCount()); nbExecutionsColumn.setIdentifier(table.getColumnCount()); nbExecutionsColumn.setHeaderValue(getString("Hits_par_requete")); table.addColumn(nbExecutionsColumn); nbExecutionsColumn.setCellRenderer(new NbExecutionsTableCellRenderer()); } table.addColumn("mean", getString("Temps_moyen")); table.addColumn("maximum", getString("Temps_max")); table.addColumn("standardDeviation", getString("Ecart_type")); table.addColumn("cpuTimeMean", getString("Temps_cpu_moyen")); table.addColumn("systemErrorPercentage", getString("erreur_systeme")); table.setColumnCellRenderer("cpuTimeMean", new MIntegerTableCellRenderer() { private static final long serialVersionUID = 1L; @Override public void setValue(Object value) { final Integer cpuTimeMean = (Integer) value; if (cpuTimeMean >= 0) { super.setValue(cpuTimeMean); } else { super.setValue(null); } } }); final Counter parentCounter = getCounterByRequestId(request); final boolean allChildHitsDisplayed = parentCounter != null && parentCounter.getChildCounterName() != null && request.hasChildHits(); if (allChildHitsDisplayed) { final String childCounterName = parentCounter.getChildCounterName(); table.addColumn("childHitsMean", getFormattedString("hits_fils_moyens", childCounterName)); table.addColumn("childDurationsMean", getFormattedString("temps_fils_moyen", childCounterName)); final ChildValueTableCellRenderer childValueTableCellRenderer = new ChildValueTableCellRenderer(); table.setColumnCellRenderer("childHitsMean", childValueTableCellRenderer); table.setColumnCellRenderer("childDurationsMean", childValueTableCellRenderer); } return tableScrollPane; }
Example 13
Source File: DatabaseInformationsPanel.java From javamelody with Apache License 2.0 | 4 votes |
private MTableScrollPane<DatabaseInformations> createScrollPane() { final MTableScrollPane<DatabaseInformations> tableScrollPane = new MTableScrollPane<>(); final MTable<DatabaseInformations> myTable = tableScrollPane.getTable(); final String[][] values = databaseInformations.getResult(); myTable.setModel(new MTableModel<String[]>(myTable) { private static final long serialVersionUID = 1L; @Override public Object getValueAt(int rowIndex, int columnIndex) { return values[rowIndex + 1][columnIndex]; } @Override public int getRowCount() { return values.length - 1; } }); for (final String header : values[0]) { final TableColumn tableColumn = new TableColumn(myTable.getColumnCount()); tableColumn.setIdentifier(header); if (header.indexOf('\n') != -1) { tableColumn.setHeaderValue(header.substring(0, header.indexOf('\n'))); // on ne peut pas mettre <html> et <br/> car les exports ne seraient pas bons // tableColumn.setHeaderValue("<html>" + header.replace("\n", "<br/>")); } else { tableColumn.setHeaderValue(header); } tableColumn.setCellRenderer(new MMultiLineTableCellRenderer() { private static final long serialVersionUID = 1L; @Override public void setValue(Object value) { super.setValue(value); if (value != null && isNumber((String) value)) { setHorizontalAlignment(SwingConstants.RIGHT); } else { setHorizontalAlignment(SwingConstants.LEFT); } } }); myTable.addColumn(tableColumn); } myTable.adjustColumnWidths(); return tableScrollPane; }
Example 14
Source File: JobInformationsPanel.java From javamelody with Apache License 2.0 | 4 votes |
private MTableScrollPane<JobInformations> createScrollPane() { final MTableScrollPane<JobInformations> tableScrollPane = new MTableScrollPane<>(); final MTable<JobInformations> myTable = tableScrollPane.getTable(); myTable.addColumn("group", getString("JobGroup")); myTable.addColumn("name", getString("JobName")); myTable.addColumn("jobClassName", getString("JobClassName")); final TableColumn stackTraceTableColumn = new TableColumn(myTable.getColumnCount()); stackTraceTableColumn.setIdentifier(myTable.getColumnCount()); stackTraceTableColumn.setHeaderValue(getString("JobLastException")); myTable.addColumn(stackTraceTableColumn); final TableColumn meanTimeTableColumn = new TableColumn(myTable.getColumnCount()); meanTimeTableColumn.setIdentifier(myTable.getColumnCount()); meanTimeTableColumn.setHeaderValue(getString("JobMeanTime")); myTable.addColumn(meanTimeTableColumn); myTable.addColumn("elapsedTime", getString("JobElapsedTime")); myTable.addColumn("previousFireTime", getString("JobPreviousFireTime")); myTable.addColumn("nextFireTime", getString("JobNextFireTime")); myTable.addColumn("repeatInterval", getString("JobPeriodOrCronExpression")); myTable.addColumn("paused", getString("JobPaused")); myTable.setColumnCellRenderer("name", new NameTableCellRenderer()); stackTraceTableColumn.setCellRenderer(new StackTraceTableCellRenderer()); meanTimeTableColumn.setCellRenderer(new MeanTimeTableCellRenderer()); myTable.setColumnCellRenderer("elapsedTime", new ElapsedTimeTableCellRenderer()); final MDateTableCellRenderer fireTimeTableCellRenderer = new MDateTableCellRenderer(); fireTimeTableCellRenderer.setDateFormat(I18N.createDateAndTimeFormat()); myTable.setColumnCellRenderer("previousFireTime", fireTimeTableCellRenderer); myTable.setColumnCellRenderer("nextFireTime", fireTimeTableCellRenderer); myTable.setColumnCellRenderer("repeatInterval", new RepeatIntervalTableCellRenderer()); // rq: on n'affiche pas le maximum, l'écart-type ou le pourcentage d'erreurs, // uniquement car cela ferait trop de colonnes dans la page myTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { final JobInformations jobInformations = getTable().getSelectedObject(); final CounterRequest counterRequest = getCounterRequest(jobInformations); if (counterRequest.getStackTrace() != null) { Utilities.showTextInPopup(JobInformationsPanel.this, counterRequest.getName(), counterRequest.getStackTrace()); } } } }); return tableScrollPane; }
Example 15
Source File: StatTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
public static void initializeTable(JTable statsTable) { JTableHeader tableHeader = statsTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); statsTable.setAutoCreateColumnsFromModel(false); DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); { TableColumn column = Utilities.createTableColumn(ABILITY_NAME, "Ability", new AbilityHeaderCellRenderer(), true); column.setIdentifier(ABILITY_COLUMN_ID); columnModel.addColumn(column); String htmlText = "<html><div align=\"center\">Final<br>Score</div></html>"; column = Utilities.createTableColumn(FINAL_ABILITY_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(new ValueRenderer()); columnModel.addColumn(column); TableCellRenderer renderer = new ModRenderer(); htmlText = "<html><div align=\"center\">Ability<br>Mod</div></html>"; column = Utilities.createTableColumn(ABILITY_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Editable<br>Score</div></html>"; column = Utilities.createTableColumn(EDITABLE_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setIdentifier(EDITABLE_COLUMN_ID); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Race<br>Adj</div></html>"; column = Utilities.createTableColumn(RACE_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); htmlText = "<html><div align=\"center\">Misc<br>Adj</div></html>"; column = Utilities.createTableColumn(MISC_ADJ, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); } statsTable.setColumnModel(columnModel); statsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); statsTable.setShowVerticalLines(false); statsTable.setCellSelectionEnabled(false); statsTable.setFocusable(false); // XXX this should be calculated relative to font size and the size of a jspinner statsTable.setRowHeight(27); statsTable.setOpaque(false); tableHeader.setFont(FontManipulation.title(statsTable.getFont())); FontManipulation.large(statsTable); }