Java Code Examples for javax.swing.table.TableColumn#getCellRenderer()
The following examples show how to use
javax.swing.table.TableColumn#getCellRenderer() .
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: TableAligner.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Installs alignment decorators in the table column at {@code colViewIndex}. * * @param table a table. * @param colViewIndex the index of the column in the table <i>view</i>. * @param alignment one of the following constants: * <ul> * <li>{@link SwingConstants#LEFT}</li> * <li>{@link SwingConstants#CENTER} (the default for image-only labels)</li> * <li>{@link SwingConstants#RIGHT}</li> * <li>{@link SwingConstants#LEADING} (the default for text-only labels)</li> * <li>{@link SwingConstants#TRAILING}</li> * </ul> */ public static void installInOneColumn(JTable table, int colViewIndex, int alignment) { TableColumn tableColumn = table.getColumnModel().getColumn(colViewIndex); TableCellRenderer headerRenderer = tableColumn.getHeaderRenderer(); if (headerRenderer == null) { headerRenderer = table.getTableHeader().getDefaultRenderer(); } if (!(headerRenderer instanceof RendererAlignmentDecorator)) { // Don't install a redundant decorator. tableColumn.setHeaderRenderer(new RendererAlignmentDecorator(headerRenderer, alignment)); } TableCellRenderer cellRenderer = tableColumn.getCellRenderer(); if (cellRenderer == null) { cellRenderer = table.getDefaultRenderer(table.getColumnClass(colViewIndex)); } if (!(cellRenderer instanceof RendererAlignmentDecorator)) { // Don't install a redundant decorator. tableColumn.setCellRenderer(new RendererAlignmentDecorator(cellRenderer, alignment)); } }
Example 2
Source File: CompositeGhidraTableCellRenderer.java From ghidra with Apache License 2.0 | 6 votes |
private TableCellRenderer getCellRenderer(JTable table, int row, int column) { // // Step 1: See if we can use our custom rendering lookup // if (table instanceof GTable) { GTable gTable = (GTable) table; return gTable.getCellRendererOverride(row, column); } // // Step 2: Locate normal JTable-style rendering // TableColumn tableColumn = table.getColumnModel().getColumn(column); TableCellRenderer renderer = tableColumn.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getColumnClass(column)); } return renderer; }
Example 3
Source File: Outline.java From netbeans with Apache License 2.0 | 6 votes |
/** Always returns the default renderer for Object.class for the tree column */ @Override public TableCellRenderer getCellRenderer(int row, int column) { int c = convertColumnIndexToModel(column); TableCellRenderer result; if (c == 0) { TableColumn tableColumn = getColumnModel().getColumn(column); TableCellRenderer renderer = tableColumn.getCellRenderer(); if (renderer == null) { result = getDefaultRenderer(Object.class); } else { result = renderer; } } else { result = super.getCellRenderer(row, column); } return result; }
Example 4
Source File: MyTreeTable.java From gameserver with Apache License 2.0 | 6 votes |
@Override public TableCellRenderer getCellRenderer(int row, int column) { if ( column == 0 ) { return super.getCellRenderer(row, column); } TableColumn tableColumn = getColumnModel().getColumn(column); TableCellRenderer renderer = tableColumn.getCellRenderer(); if (renderer == null) { Object value = this.getValueAt(row, column); if ( value != null ) { renderer = getDefaultRenderer(value.getClass()); } else { renderer = getDefaultRenderer(getColumnClass(column)); } } return renderer; }
Example 5
Source File: EditableTableHeaderColumn.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public void copyValues(TableColumn base) { modelIndex = base.getModelIndex(); identifier = base.getIdentifier(); width = base.getWidth(); minWidth = base.getMinWidth(); setPreferredWidth(base.getPreferredWidth()); maxWidth = base.getMaxWidth(); headerRenderer = base.getHeaderRenderer(); headerValue = base.getHeaderValue(); cellRenderer = base.getCellRenderer(); cellEditor = base.getCellEditor(); isResizable = base.getResizable(); }
Example 6
Source File: ObjectivePanel.java From triplea with GNU General Public License v3.0 | 5 votes |
/** * Look through all columns and get the renderer. If it is also a TextAreaRenderer, we look at * the maximum height in its hash table for this row. */ private static int findTotalMaximumRowSize(final JTable table, final int row) { int maximumHeight = 0; final Enumeration<?> columns = table.getColumnModel().getColumns(); while (columns.hasMoreElements()) { final TableColumn tc = (TableColumn) columns.nextElement(); final TableCellRenderer cellRenderer = tc.getCellRenderer(); if (cellRenderer instanceof EditorPaneTableCellRenderer) { final EditorPaneTableCellRenderer tar = (EditorPaneTableCellRenderer) cellRenderer; maximumHeight = Math.max(maximumHeight, tar.findMaximumRowSize(table, row)); } } return maximumHeight; }
Example 7
Source File: PropertyTable.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public TableCellRenderer getCellRenderer( final int row, final int viewColumn ) { final TableModel tableModel = getModel(); if ( tableModel instanceof PropertyTableModel ) { final PropertyTableModel model = (PropertyTableModel) getModel(); final int column = convertColumnIndexToModel( viewColumn ); final Class columnClass = model.getClassForCell( row, column ); if ( columnClass.isArray() ) { return arrayCellRenderer; } final PropertyEditor propertyEditor = model.getEditorForCell( row, column ); if ( propertyEditor != null ) { propertyEditorCellRenderer.setPropertyEditor( propertyEditor ); return propertyEditorCellRenderer; } final TableColumn tableColumn = getColumnModel().getColumn( column ); final TableCellRenderer renderer = tableColumn.getCellRenderer(); if ( renderer != null ) { return renderer; } final TableCellRenderer defaultRenderer = getDefaultRenderer( columnClass ); if ( defaultRenderer != null ) { return defaultRenderer; } if ( logger.isTraceEnabled() ) { logger.trace( "No renderer for column class " + columnClass ); // NON-NLS } return getDefaultRenderer( Object.class ); } return super.getCellRenderer( row, viewColumn ); }
Example 8
Source File: ElementMetaDataTable.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public TableCellRenderer getCellRenderer( final int row, final int viewColumn ) { final int column = convertColumnIndexToModel( viewColumn ); final Object value = getModel().getValueAt( row, column ); if ( value instanceof GroupingHeader ) { return groupingCellRenderer; } final ElementMetaDataTableModel model = (ElementMetaDataTableModel) getModel(); final Class columnClass = model.getClassForCell( row, column ); if ( columnClass.isArray() ) { return arrayCellRenderer; } final PropertyEditor propertyEditor = model.getEditorForCell( row, column ); if ( propertyEditor != null ) { propertyEditorCellRenderer.setPropertyEditor( propertyEditor ); return propertyEditorCellRenderer; } final TableColumn tableColumn = getColumnModel().getColumn( column ); final TableCellRenderer renderer = tableColumn.getCellRenderer(); if ( renderer != null ) { return renderer; } final TableCellRenderer defaultRenderer = getDefaultRenderer( columnClass ); if ( defaultRenderer != null ) { return defaultRenderer; } if ( logger.isTraceEnabled() ) { logger.trace( "No renderer for column class " + columnClass ); // NON-NLS } return getDefaultRenderer( Object.class ); }
Example 9
Source File: EditableHeaderTableColumn.java From chipster with MIT License | 5 votes |
public void copyValues(TableColumn base) { modelIndex = base.getModelIndex(); identifier = base.getIdentifier(); width = base.getWidth(); minWidth = base.getMinWidth(); setPreferredWidth(base.getPreferredWidth()); maxWidth = base.getMaxWidth(); headerRenderer = base.getHeaderRenderer(); headerValue = base.getHeaderValue(); cellRenderer = base.getCellRenderer(); cellEditor = base.getCellEditor(); isResizable = base.getResizable(); }
Example 10
Source File: TableUISupport.java From netbeans with Apache License 2.0 | 4 votes |
private static void setRenderer(TableColumn column) { if (!(column.getCellRenderer() instanceof TableClassNameRenderer)) { column.setCellRenderer(new TableClassNameRenderer()); } }
Example 11
Source File: TableUISupport.java From jeddict with Apache License 2.0 | 4 votes |
private static void setRenderer(TableColumn column) { if (!(column.getCellRenderer() instanceof TableClassNameRenderer)) { column.setCellRenderer(new TableClassNameRenderer()); } }
Example 12
Source File: ObjectPropertyViewerPanel.java From opensim-gui with Apache License 2.0 | 4 votes |
public TableCellRenderer getCellRenderer(int row, int column) { TableColumn tableColumn = getColumnModel().getColumn(column); TableCellRenderer renderer = tableColumn.getCellRenderer(); if (renderer == null) renderer = getDefaultRenderer(model.getCellClass(adapter.nodeForRow(row), convertColumnIndexToModel(column))); return renderer; }