private void configureTableAppearance() { tableDevices.setOpaque(false); ((DefaultTableCellRenderer) tableDevices.getDefaultRenderer(Object.class)).setOpaque(false); tableDevices.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); tableDevices.getColumnModel().getColumn(0).setPreferredWidth(100); tableDevices.getColumnModel().getColumn(1).setMinWidth(85); tableDevices.getColumnModel().getColumn(1).setMaxWidth(85); tableDevices.getColumnModel().getColumn(2).setMinWidth(215); tableDevices.getColumnModel().getColumn(2).setMaxWidth(215); tableDevices.getColumnModel().getColumn(2).setCellRenderer(new ConnectDisconnectRenderer()); tableDevices.getColumnModel() .getColumn(2) .setCellEditor(new ConnectDisconnectEditor(new JCheckBox(), this)); }
KeyStroke keyStroke = KeyStroke.getKeyStroke("ENTER"); textArea.getInputMap().put(keyStroke, "none"); JScrollPane scrollPane = new JScrollPane( textArea ); getContentPane().add( scrollPane ); buttons.add( ok ); buttons.add( cancel ); getContentPane().add(buttons, BorderLayout.SOUTH); pack(); }; JTable table = new JTable(data, columnNames); table.getColumnModel().getColumn(1).setPreferredWidth(300); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane(table); table.getColumnModel().getColumn(1).setCellEditor( popupEditor );
protected void addCellEditor(TableColumnModel columnModel) { final FloatCellEditor pixelCellEditor = new FloatCellEditor(); columnModel.getColumn(0).setCellEditor(pixelCellEditor); columnModel.getColumn(1).setCellEditor(pixelCellEditor); columnModel.getColumn(2).setCellEditor(new FloatCellEditor(-180, 180)); columnModel.getColumn(3).setCellEditor(new FloatCellEditor(-90, 90)); columnModel.getColumn(4).setCellEditor(new ColorCE()); }
JTable table = new JTable(model); table.getColumn(columns[1]).setCellEditor(new DefaultCellEditor(new JComboBox<>(dataStrings1))); table.getColumn(columns[2]).setCellEditor(new DefaultCellEditor(new JComboBox<>(dataStrings2))); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane); frame.pack(); frame.setLocationByPlatform(true);
JTable table = new JTable(model); model.addColumn("Object", new Object[] { "object" }); Enumeration e = table.getColumnModel().getColumns(); TableColumn col = (TableColumn) e.nextElement(); col.setCellEditor(table.getDefaultEditor(Boolean.class)); f.add(new JScrollPane(table)); f.setVisible(true);
/** * Constructor * * @param basic * set to true if you only want to show preferred properties */ public PropertyPane(boolean basic) { super(new BorderLayout()); m_tablemodel = new PropertyTableModel(); if (basic) m_tablemodel.setFilter(PropertyTableModel.VIEW_PREFERRED); m_tablemodel.addTableModelListener(this); m_columnModel = new PropertyColumnModel(); m_table = new JTable(m_tablemodel, m_columnModel); m_table.setShowGrid(true); m_table.setRowHeight(ROW_HEIGHT); m_table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); m_renderer = new PropertyValueRenderer(m_tablemodel); m_editor = new PropertyValueEditor(m_tablemodel); m_columnModel.getColumn(PropertyTableModel.COL_VALUE).setCellRenderer(m_renderer); m_columnModel.getColumn(PropertyTableModel.COL_VALUE).setCellEditor(m_editor); add(new JScrollPane(m_table), BorderLayout.CENTER); }
private void setColumnEditors(InnerTableModel model) { TableColumnModel columnModel = table.getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableCellEditor cellEditor = model.getCellEditor(i); if (cellEditor != null) { columnModel.getColumn(i).setCellEditor(cellEditor); } } }
private void configureTreedView() { if (rowsModel instanceof ArrayTreedModel && columnModel.getColumnCount() > 0) { TableColumn tCol = columnModel.getColumn(0); tCol.setCellRenderer(new InsettedTreeRenderer<>(tCol.getCellRenderer(), new TreeColumnLeadingComponent<>(deepModel, false, closedFolderIcon, openFolderIcon, leafIcon))); tCol.setCellEditor(new InsettedTreeEditor<>(tCol.getCellEditor(), new TreeColumnLeadingComponent<>(deepModel, true, closedFolderIcon, openFolderIcon, leafIcon))); } }
// Create a table. JTable table = new JTable(new DemoTableModel()); // Add the DateTimeTableEditor as the default editor and renderer for // the LocalDateTime data type. table.setDefaultEditor(LocalDateTime.class, new DateTimeTableEditor()); table.setDefaultRenderer(LocalDateTime.class, new DateTimeTableEditor()); // Explicitly set the default editor and renderer for column index 0. TableColumn column = table.getColumnModel().getColumn(0); column.setCellEditor(table.getDefaultEditor(LocalDateTime.class)); column.setCellRenderer(table.getDefaultRenderer(LocalDateTime.class));
public static void main( String[] args ) { JFrame frame = new JFrame(); JTable table = new JTable(data,columnNames); TableColumnModel tcm = table.getColumnModel(); TableColumn tc = tcm.getColumn(1); tc.setCellEditor(new SpinnerEditor()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(table); frame.pack(); frame.setVisible(true);
public TablesButtonColumn(JTable table, Action action, int column) { super(); this.table = table; this.action = action; renderButton = new JButton(); editButton = new JButton(); editButton.setFocusPainted(false); editButton.addActionListener(this); setGUISize(); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(column).setCellRenderer(this); columnModel.getColumn(column).setCellEditor(this); table.addMouseListener(this); }
model.addRow(new Object[]{"Pual Reed Smith Standard 24", 1999.99d, 1470.58d}); JTable table = new JTable(model); table.setPreferredScrollableViewportSize(new Dimension(500, 300)); priceUSD.setCellEditor(new CurrencyEditor(Locale.US)); priceEUR.setCellEditor(new CurrencyEditor(Locale.GERMANY)); content.add(new JScrollPane(table)); frame.getContentPane().add(content); frame.pack(); frame.setLocationRelativeTo(null);
protected void addCellEditor(TableColumnModel columnModel) { final DecimalCellEditor pixelCellEditor = new DecimalCellEditor(); columnModel.getColumn(0).setCellEditor(pixelCellEditor); columnModel.getColumn(1).setCellEditor(pixelCellEditor); columnModel.getColumn(2).setCellEditor(new DecimalCellEditor(-180, 180)); columnModel.getColumn(3).setCellEditor(new DecimalCellEditor(-90, 90)); columnModel.getColumn(4).setCellEditor(new ColorTableCellEditor()); }
// Create a table. JTable table = new JTable(new DemoTableModel()); // Add the DateTimeTableEditor as the default editor and renderer for // the LocalDateTime data type. table.setDefaultEditor(LocalDateTime.class, new DateTimeTableEditor()); table.setDefaultRenderer(LocalDateTime.class, new DateTimeTableEditor()); // Explicitly set the default editor and renderer for column index 0. TableColumn column = table.getColumnModel().getColumn(0); column.setCellEditor(table.getDefaultEditor(LocalDateTime.class)); column.setCellRenderer(table.getDefaultRenderer(LocalDateTime.class));
{"button 2", "bar"}}, new Object[]{"Button", "String"}); JTable table = new JTable(dm); table.getColumn("Button").setCellRenderer(new ButtonRenderer()); table.getColumn("Button").setCellEditor(new ButtonEditor(new JCheckBox())); JScrollPane scroll = new JScrollPane(table); table.getColumnModel().getColumn(0).setPreferredWidth(100);//so buttons will fit and not be shown butto.. frame.add(scroll);
public void setDeckEditorMode(DeckEditorMode mode) { if (mode == DeckEditorMode.FREE_BUILDING) { // activate spinner for card number change mainModel.setNumberEditable(true); TableColumnModel tcm = mainTable.getColumnModel(); TableColumn tc = tcm.getColumn(0); tc.setMaxWidth(55); tc.setMinWidth(55); tc.setPreferredWidth(55); tc.setCellEditor(new TableSpinnerEditor(this)); } }
/** * Permet d'initialiser les renderer,editor pour ce model. */ public void setRendererAndEditor(final TableColumnModel _m) { TableColumn col= _m.getColumn(0); col.setCellRenderer(BGrapheController.createNameContourRenderer()); col= _m.getColumn(1); col.setCellEditor(BGrapheController.createVisibleCellEditor()); col.setCellRenderer(BGrapheController.createVisibleCellRenderer()); col.setWidth(5); }
/** * This method initializes attributesTable * * @return javax.swing.JTable */ private JTable getAttributesTable() { if (attributesTable == null) { attributesTable = new JTable(attributesTableModel); TableColumn col = attributesTable.getColumnModel().getColumn(7); col.setCellEditor(new ValueTableCellEditor()); for (int i = 0; i < attributesTableModel.getColumnCount(); i++) { col = attributesTable.getColumnModel().getColumn(i); if (i == 0 || i == 7) { col.setPreferredWidth(120); } else { col.setPreferredWidth(40); } } } return attributesTable; }
public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setCellEditor(editor); }
public PrefixMapperTable(PrefixDocumentFormat prefixManager) { super(new PrefixMapperTableModel(prefixManager)); setShowGrid(true); setRowHeight(getRowHeight() + 3); getColumnModel().getColumn(0).setPreferredWidth(150); getColumnModel().getColumn(1).setPreferredWidth(600); getColumnModel().getColumn(0).setCellEditor(new PrefixTableCellEditor()); getColumnModel().getColumn(1).setCellEditor(new PrefixTableCellEditor()); this.prefixManager = prefixManager; }