Java Code Examples for javax.swing.table.JTableHeader#setResizingAllowed()
The following examples show how to use
javax.swing.table.JTableHeader#setResizingAllowed() .
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: SkillPointTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 7 votes |
public static void initializeTable(JTable table) { table.setAutoCreateColumnsFromModel(false); JTableHeader header = table.getTableHeader(); TableColumnModel columns = new DefaultTableColumnModel(); TableCellRenderer headerRenderer = header.getDefaultRenderer(); columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false)); columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true)); TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false); remainCol.setCellRenderer(new BoldNumberRenderer()); columns.addColumn(remainCol); columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false)); table.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER)); table.setColumnModel(columns); table.setFocusable(false); header.setReorderingAllowed(false); header.setResizingAllowed(false); }
Example 2
Source File: JTableHeaderEditor.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Object getDesignValue() { Object value = null; try { value = property.getTargetValue(); if (value instanceof JTableHeader) { JTableHeader header = (JTableHeader)value; header.setResizingAllowed(resizingAllowed); header.setReorderingAllowed(reorderingAllowed); } } catch (IllegalAccessException iaex) { Logger.getLogger(getClass().getName()).log(Level.INFO, iaex.getMessage(), iaex); } catch (InvocationTargetException itex) { Logger.getLogger(getClass().getName()).log(Level.INFO, itex.getMessage(), itex); } return value; }
Example 3
Source File: ClassLevelTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
public static void initializeTable(JTable classLevelTable) { JTableHeader tableHeader = classLevelTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); TableColumnModel columnModel = new DefaultTableColumnModel(); TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer(); columnModel.addColumn(Utilities.createTableColumn(0, "Level", headerRenderer, false)); columnModel.addColumn(Utilities.createTableColumn(1, "HP", headerRenderer, false)); columnModel.addColumn(Utilities.createTableColumn(2, "Class (All Levels In Class)", headerRenderer, true)); classLevelTable.setColumnModel(columnModel); classLevelTable.setAutoCreateColumnsFromModel(false); classLevelTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); classLevelTable.setFocusable(false); classLevelTable.setCellSelectionEnabled(false); classLevelTable.setRowHeight(20); }
Example 4
Source File: SkillPointTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
public static void initializeTable(JTable table) { table.setAutoCreateColumnsFromModel(false); JTableHeader header = table.getTableHeader(); TableColumnModel columns = new DefaultTableColumnModel(); TableCellRenderer headerRenderer = header.getDefaultRenderer(); columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false)); columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true)); TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false); remainCol.setCellRenderer(new BoldNumberRenderer()); columns.addColumn(remainCol); columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false)); table.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER)); table.setColumnModel(columns); table.setFocusable(false); header.setReorderingAllowed(false); header.setResizingAllowed(false); }
Example 5
Source File: ClassLevelTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
public static void initializeTable(JTable classLevelTable) { JTableHeader tableHeader = classLevelTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); TableColumnModel columnModel = new DefaultTableColumnModel(); TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer(); columnModel.addColumn(Utilities.createTableColumn(0, "Level", headerRenderer, false)); columnModel.addColumn(Utilities.createTableColumn(1, "HP", headerRenderer, false)); columnModel.addColumn(Utilities.createTableColumn(2, "Class (All Levels In Class)", headerRenderer, true)); classLevelTable.setColumnModel(columnModel); classLevelTable.setAutoCreateColumnsFromModel(false); classLevelTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); classLevelTable.setFocusable(false); classLevelTable.setCellSelectionEnabled(false); classLevelTable.setRowHeight(20); }
Example 6
Source File: MosaicExpressionsPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private JScrollPane createVariablesTable(final String labelName) { variablesTable = new JTable(); variablesTable.setName(labelName); variablesTable.setRowSelectionAllowed(true); bindingCtx.bind("variables", new VariablesTableAdapter(variablesTable)); bindingCtx.bindEnabledState("variables", false, "updateMode", true); variablesTable.addMouseListener(createExpressionEditorMouseListener(variablesTable, false)); final JTableHeader tableHeader = variablesTable.getTableHeader(); tableHeader.setName(labelName); tableHeader.setReorderingAllowed(false); tableHeader.setResizingAllowed(true); final TableColumnModel columnModel = variablesTable.getColumnModel(); columnModel.setColumnSelectionAllowed(false); final TableColumn nameColumn = columnModel.getColumn(0); nameColumn.setPreferredWidth(100); nameColumn.setCellRenderer(new TCR()); final TableColumn expressionColumn = columnModel.getColumn(1); expressionColumn.setPreferredWidth(400); expressionColumn.setCellRenderer(new TCR()); final ExprEditor exprEditor = new ExprEditor(false); expressionColumn.setCellEditor(exprEditor); bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { final boolean enabled = Boolean.FALSE.equals(evt.getNewValue()); exprEditor.button.setEnabled(enabled); } }); final JScrollPane scrollPane = new JScrollPane(variablesTable); scrollPane.setName(labelName); scrollPane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 150)); return scrollPane; }
Example 7
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private void initCellSize(int size) { setRowHeight(size); JTableHeader tableHeader = getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); TableColumnModel m = getColumnModel(); for (int i = 0; i < m.getColumnCount(); i++) { TableColumn col = m.getColumn(i); col.setMinWidth(size); col.setMaxWidth(size); } setBorder(BorderFactory.createLineBorder(Color.BLACK)); }
Example 8
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new BorderLayout()); monthTable.setDefaultRenderer(LocalDate.class, new CalendarTableRenderer()); monthTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); monthTable.setCellSelectionEnabled(true); monthTable.setFillsViewportHeight(true); JTableHeader header = monthTable.getTableHeader(); header.setResizingAllowed(false); header.setReorderingAllowed(false); ((JLabel) header.getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER); updateMonthView(LocalDate.of(2020, 8, 1)); JButton prev = new JButton("<"); prev.addActionListener(e -> updateMonthView(getCurrentLocalDate().minusMonths(1))); JButton next = new JButton(">"); next.addActionListener(e -> updateMonthView(getCurrentLocalDate().plusMonths(1))); JPanel p = new JPanel(new BorderLayout()); p.add(monthLabel); p.add(prev, BorderLayout.WEST); p.add(next, BorderLayout.EAST); JScrollPane scroll = new JScrollPane(monthTable); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(p, BorderLayout.NORTH); add(scroll); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setPreferredSize(new Dimension(320, 240)); }
Example 9
Source File: TubesConfigPanel.java From netbeans with Apache License 2.0 | 5 votes |
public TubeTable() { JTableHeader header = getTableHeader(); header.setResizingAllowed(false); header.setReorderingAllowed(false); ListSelectionModel model = getSelectionModel(); model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); model.addListSelectionListener(new TubeListSelectionListener()); }
Example 10
Source File: TubesProjectConfigPanel.java From netbeans with Apache License 2.0 | 5 votes |
public TubeTable(boolean client) { super(); this.client = client; JTableHeader header = getTableHeader(); header.setResizingAllowed(false); header.setReorderingAllowed(false); ListSelectionModel model = getSelectionModel(); model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); model.addListSelectionListener(new TubeListSelectionListener(client)); }
Example 11
Source File: MessageHandlerPanel.java From netbeans with Apache License 2.0 | 5 votes |
public HandlerTable() { JTableHeader header = getTableHeader(); header.setResizingAllowed(false); header.setReorderingAllowed(false); ListSelectionModel model = getSelectionModel(); model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); model.addListSelectionListener(new HandlerListSelectionListener()); }
Example 12
Source File: JTableHeaderEditor.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Object getDesignValue(Object target) { // PENDING JTableHeader header = null; if (target instanceof javax.swing.JTable) { header = ((javax.swing.JTable)target).getTableHeader(); header.setResizingAllowed(resizingAllowed); header.setReorderingAllowed(reorderingAllowed); } return header; }
Example 13
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 14
Source File: JXTableRowHeader.java From netbeans with Apache License 2.0 | 4 votes |
public JTableHeader getTableHeader() { JTableHeader header = headerTable.getTableHeader(); header.setReorderingAllowed(false); header.setResizingAllowed(false); return header; }
Example 15
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
private MainPanel() { super(new BorderLayout()); monthTable.setDefaultRenderer(LocalDate.class, new CalendarTableRenderer()); monthTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); monthTable.setCellSelectionEnabled(true); monthTable.setRowHeight(20); monthTable.setFillsViewportHeight(true); JTableHeader header = monthTable.getTableHeader(); header.setResizingAllowed(false); header.setReorderingAllowed(false); ((JLabel) header.getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER); ListSelectionListener selectionListener = e -> { if (!e.getValueIsAdjusting()) { LocalDate ld = (LocalDate) monthTable.getValueAt(monthTable.getSelectedRow(), monthTable.getSelectedColumn()); dateLabel.setText(ld.toString()); } }; monthTable.getSelectionModel().addListSelectionListener(selectionListener); monthTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); updateMonthView(realLocalDate); JButton prev = new JButton("<"); prev.addActionListener(e -> updateMonthView(getCurrentLocalDate().minusMonths(1))); JButton next = new JButton(">"); next.addActionListener(e -> updateMonthView(getCurrentLocalDate().plusMonths(1))); JPanel p = new JPanel(new BorderLayout()); p.add(monthLabel); p.add(prev, BorderLayout.WEST); p.add(next, BorderLayout.EAST); add(p, BorderLayout.NORTH); add(new JScrollPane(monthTable)); add(dateLabel, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setPreferredSize(new Dimension(320, 240)); }
Example 16
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 17
Source File: MosaicExpressionsPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private JScrollPane createConditionsTable(final String labelName) { conditionsTable = new JTable() { private static final long serialVersionUID = 1L; @Override public Class getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return super.getColumnClass(column); } } }; conditionsTable.setName(labelName); conditionsTable.setRowSelectionAllowed(true); bindingCtx.bind("conditions", new ConditionsTableAdapter(conditionsTable)); bindingCtx.bindEnabledState("conditions", false, "updateMode", true); conditionsTable.addMouseListener(createExpressionEditorMouseListener(conditionsTable, true)); final JTableHeader tableHeader = conditionsTable.getTableHeader(); tableHeader.setName(labelName); tableHeader.setReorderingAllowed(false); tableHeader.setResizingAllowed(true); final TableColumnModel columnModel = conditionsTable.getColumnModel(); columnModel.setColumnSelectionAllowed(false); final TableColumn nameColumn = columnModel.getColumn(0); nameColumn.setPreferredWidth(100); nameColumn.setCellRenderer(new TCR()); final TableColumn expressionColumn = columnModel.getColumn(1); expressionColumn.setPreferredWidth(360); expressionColumn.setCellRenderer(new TCR()); final ExprEditor cellEditor = new ExprEditor(true); expressionColumn.setCellEditor(cellEditor); bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { final boolean enabled = Boolean.FALSE.equals(evt.getNewValue()); cellEditor.button.setEnabled(enabled); } }); final TableColumn outputColumn = columnModel.getColumn(2); outputColumn.setPreferredWidth(40); final JScrollPane pane = new JScrollPane(conditionsTable); pane.setName(labelName); pane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 80)); return pane; }