@Override protected void createDefaultRenderers() { super.createDefaultRenderers(); UIDefaults.LazyValue booleanRenderer = new UIDefaults.LazyValue() { @Override public Object createValue(@NotNull UIDefaults table) { DefaultCellEditor editor = new DefaultCellEditor(GuiUtils.createUndoableTextField()); editor.setClickCountToStart(1); return new BooleanTableCellRenderer(); } }; //noinspection unchecked defaultRenderersByColumnClass.put(boolean.class, booleanRenderer); //noinspection unchecked defaultRenderersByColumnClass.put(Boolean.class, booleanRenderer); }
public void setTableEditor(JTable table) { this.table = table; TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(COL_CHECK).setCellRenderer(new BooleanTableCellRenderer()); columnModel.getColumn(COL_CHECK).setCellEditor(new BooleanTableCellEditor()); columnModel.getColumn(COL_CHECK).setPreferredWidth(50); columnModel.getColumn(COL_TABLE).setPreferredWidth(100); JTableHeader header = table.getTableHeader(); header.setDefaultRenderer(new ClassTableHeaderRenderer(table, true)); }
@Override public TableCellRenderer getRenderer(final IdeaPluginDescriptor ideaPluginDescriptor) { return new BooleanTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value == null ? Boolean.TRUE : value, isSelected, hasFocus, row, column); } }; }
public void methodsSize(int methods) { myTableModel = new DefaultTableModel(methods, 2); myMethodsTable.setModel(myTableModel); TableColumn checkColumn = myMethodsTable.getColumnModel().getColumn(0); TableUtil.setupCheckboxColumn(checkColumn); checkColumn.setCellRenderer(new BooleanTableCellRenderer()); checkColumn.setCellEditor(new DefaultCellEditor(new JCheckBox())); myMethodsTable.getColumnModel().getColumn(1).setHeaderValue("Test method"); checkColumn.setHeaderValue(""); getOKAction().setEnabled(true); }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, final boolean hasFocus, int row, int column) { JPanel panel = new JPanel(); final Component component = super.getTableCellRendererComponent(table, ((Pair)value).getFirst(), isSelected, hasFocus, row, column); panel.add(component); final Component component1 = new BooleanTableCellRenderer().getTableCellRendererComponent(table, ((Pair)value).getSecond(), isSelected, hasFocus, row, column); panel.add(component1); return panel; }
public static void setColumns(@NotNull JTable table) { StringResourceTableModel model = (StringResourceTableModel) table.getModel(); Enumeration<TableColumn> columns = table.getColumnModel().getColumns(); while (columns.hasMoreElements()) { TableColumn column = columns.nextElement(); if (column.getModelIndex() == ConstantColumn.UNTRANSLATABLE.ordinal()) { column.setCellRenderer(new BooleanTableCellRenderer()); } else { column.setCellRenderer(CELL_RENDERER); } int index = column.getModelIndex(); FontMetrics fontMetrics = table.getFontMetrics(table.getFont()); Locale locale = model.localeOfColumn(index); HeaderCellRenderer renderer = locale == null ? new ConstantHeaderCellRenderer(index, fontMetrics) : new TranslationHeaderCellRenderer(fontMetrics, locale); column.setHeaderRenderer(renderer); // Sets Key and Default Value columns to initially display at full width and all others to be collapsed int width; if (ConstantColumn.KEY.ordinal() == index || ConstantColumn.DEFAULT_VALUE.ordinal() == index) { width = renderer.getFullExpandedWidth(); } else { width = renderer.getCollapsedWidth(); } setPreferredWidth(column, width); } expandToViewportWidthIfNecessary(table, -1); }
CloudLibraryTable(List<CloudLibrary> libraries) { super(new CloudLibraryTableModel(libraries)); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setDefaultRenderer(CloudLibrary.class, new CloudLibraryRenderer()); setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer()); setDefaultEditor(Boolean.class, new BooleanTableCellEditor()); TableUtil.setupCheckboxColumn(getColumnModel().getColumn(1)); }
public TableCellRenderer getRenderer(final IdeaPluginDescriptor ideaPluginDescriptor) { return new BooleanTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value == null ? Boolean.TRUE : value, isSelected, hasFocus, row, column); } }; }
private JScrollPane createTablePanel() { myTableModel = new MyTableModel(); myTable = new Table(myTableModel); myTable.setSurrendersFocusOnKeystroke(true); myTable.getTableHeader().setReorderingAllowed(false); final TableColumnModel columnModel = myTable.getColumnModel(); columnModel.getColumn(SKIP_SETTER).setCellRenderer(new BooleanTableCellRenderer()); myTable.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { final int[] selectedRows = myTable.getSelectedRows(); for (final int selectedRow : selectedRows) { final ParameterData parameterData = myTableModel.getParamData(selectedRow); if (parameterData.getDefaultValue() != null) { parameterData.setInsertSetter(!parameterData.isInsertSetter()); } } TableUtil.selectRows(myTable, selectedRows); } }, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED ); myTable.setPreferredScrollableViewportSize(new Dimension(550, myTable.getRowHeight() * 12)); myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); //final Border titledBorder = IdeBorderFactory.createBoldTitledBorder("Parameters to Pass to the Builder"); //final Border emptyBorder = BorderFactory.createEmptyBorder(0, 5, 5, 5); //final Border border = BorderFactory.createCompoundBorder(titledBorder, emptyBorder); //scrollPane.setBorder(border); return scrollPane; }
public BooleanColumnInfo(final String name) { super(name, new BooleanTableCellRenderer()); }
@Nullable @Override public TableCellRenderer getRenderer(AbstractVariableData data) { return new BooleanTableCellRenderer(); }