Java Code Examples for javax.swing.JTable#setRowHeight()
The following examples show how to use
javax.swing.JTable#setRowHeight() .
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: KeysTableView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 2
Source File: GfxdTop.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public GfxdTop() { super(new GridLayout(1,0)); tmodel = new StatementTableModel(); queryStats = new ClusterStatistics(); JTable table = new JTable(tmodel); table.setPreferredScrollableViewportSize(new Dimension(500, 300)); table.setDefaultRenderer(Double.class, new DoubleRenderer()); table.setIntercellSpacing(new Dimension(6,3)); table.setRowHeight(table.getRowHeight() + 4); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); }
Example 3
Source File: TableUtils.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable, JToggleButton button) { rowheaderTable.setAutoCreateColumnsFromModel(false); // force the tables to share models rowheaderTable.setModel(table.getModel()); rowheaderTable.setSelectionModel(table.getSelectionModel()); rowheaderTable.setRowHeight(table.getRowHeight()); rowheaderTable.setIntercellSpacing(table.getIntercellSpacing()); rowheaderTable.setShowGrid(false); rowheaderTable.setFocusable(false); TableColumn column = new TableColumn(-1); column.setHeaderValue(new Object()); column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button)); rowheaderTable.addColumn(column); rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(table); scrollPane.setRowHeaderView(rowheaderTable); return scrollPane; }
Example 4
Source File: MapRuleRender.java From finalspeed-91yun with GNU General Public License v2.0 | 6 votes |
void update(MapRule rule,JTable table,int row){ this.rule=rule; int rowHeight=50; int h=table.getRowHeight(row); if(h!=rowHeight){ table.setRowHeight(row, rowHeight); } String name=rule.getName(); if(name==null){ name="无"; }else if(name.trim().equals("")){ name="无"; } label_wan_address.setText("名称: "+rule.name+" 加速端口: "+rule.dst_port); label2.setText("本地端口: "+rule.getListen_port()); }
Example 5
Source File: TablePagePanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override public void customise(JTable table, JTextArea component, String value, int rowIndex, int colIndex) { if (!wrappingRows.contains(rowIndex)) { return; } component.setLineWrap(true); component.setWrapStyleWord(true); int max = 230; // if ((table).getCellSpanAt(rowIndex, colIndex).getColumnSpan() == table.getColumnCount()) { // max *= 2; // } int numRows = countLines(component, value, max); if (numRows > 1) { int rowHeight = table.getRowHeight() * numRows; table.setRowHeight(rowIndex, Math.max(table.getRowHeight(rowIndex), rowHeight)); } }
Example 6
Source File: PropertiesTable.java From netbeans with Apache License 2.0 | 6 votes |
private void init(JLabel label, String[] columns) { tableModel = new PropertiesTableModel(columns); tableModel.addTableModelListener(this); table = new JTable(tableModel); table.getTableHeader().setReorderingAllowed(false); table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer()); //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor()); table.setRowHeight(table.getRowHeight()); table.addAncestorListener(this); component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); component.setPreferredSize(new Dimension(340, 150)); table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PropertiesTable.class, "ACSN_PropertiesTable")); // NOI18N label.setLabelFor(table); setColumns(columns); }
Example 7
Source File: TableUtils.java From lucene-solr with Apache License 2.0 | 6 votes |
public static void setupTable(JTable table, int selectionModel, TableModel model, MouseListener mouseListener, int... colWidth) { table.setFillsViewportHeight(true); table.setFont(StyleConstants.FONT_MONOSPACE_LARGE); table.setRowHeight(StyleConstants.TABLE_ROW_HEIGHT_DEFAULT); table.setShowHorizontalLines(true); table.setShowVerticalLines(false); table.setGridColor(Color.lightGray); table.getColumnModel().setColumnMargin(StyleConstants.TABLE_COLUMN_MARGIN_DEFAULT); table.setRowMargin(StyleConstants.TABLE_ROW_MARGIN_DEFAULT); table.setSelectionMode(selectionModel); if (model != null) { table.setModel(model); } else { table.setModel(new DefaultTableModel()); } if (mouseListener != null) { table.removeMouseListener(mouseListener); table.addMouseListener(mouseListener); } for (int i = 0; i < colWidth.length; i++) { table.getColumnModel().getColumn(i).setMinWidth(colWidth[i]); table.getColumnModel().getColumn(i).setMaxWidth(colWidth[i]); } }
Example 8
Source File: VariablesWindow.java From cstc with GNU General Public License v3.0 | 5 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Dimension preferredSize = getPreferredSize(); setText(value.toString()); setSize(preferredSize.width, getPreferredSize().height); if (table.getRowHeight(row) != getPreferredSize().height) { table.setRowHeight(row, getPreferredSize().height); } setColumnWidth(preferredSize); return this; }
Example 9
Source File: AttrTable.java From Logisim with GNU General Public License v3.0 | 5 votes |
public AttrTable(Window parent) { super(new BorderLayout()); this.parent = parent; titleEnabled = true; title = new TitleLabel(); title.setHorizontalAlignment(SwingConstants.CENTER); title.setVerticalAlignment(SwingConstants.CENTER); tableModel = new TableModelAdapter(parent, NULL_ATTR_MODEL); table = new JTable(tableModel); table.setDefaultEditor(Object.class, editor); table.setTableHeader(null); table.setRowHeight(20); Font baseFont = title.getFont(); int titleSize = Math.round(baseFont.getSize() * 1.2f); Font titleFont = baseFont.deriveFont((float) titleSize).deriveFont(Font.BOLD); title.setFont(titleFont); Color bgColor = new Color(240, 240, 240); setBackground(bgColor); table.setBackground(bgColor); Object renderer = table.getDefaultRenderer(String.class); if (renderer instanceof JComponent) { ((JComponent) renderer).setBackground(Color.WHITE); } JScrollPane tableScroll = new JScrollPane(table); this.add(title, BorderLayout.PAGE_START); this.add(tableScroll, BorderLayout.CENTER); LocaleManager.addLocaleListener(this); localeChanged(); }
Example 10
Source File: Table.java From Spark with Apache License 2.0 | 5 votes |
@Override public Component getTableCellRendererComponent(JTable jTable, Object obj, boolean isSelected, boolean hasFocus, int row, int column) { // set color & border here setText(obj == null ? "" : obj.toString()); setSize(jTable.getColumnModel().getColumn(column).getWidth(), getPreferredSize().height); if (jTable.getRowHeight(row) != getPreferredSize().height) { jTable.setRowHeight(row, getPreferredSize().height); } return this; }
Example 11
Source File: GameHistoryPanel.java From BlackWidow-Chess with GNU Lesser General Public License v2.1 | 5 votes |
GameHistoryPanel() { this.setLayout(new BorderLayout()); this.model = new DataModel(); final JTable table = new JTable(model); table.setRowHeight(15); this.scrollPane = new JScrollPane(table); scrollPane.setColumnHeaderView(table.getTableHeader()); scrollPane.setPreferredSize(HISTORY_PANEL_DIMENSION); this.add(scrollPane, BorderLayout.CENTER); this.setVisible(true); }
Example 12
Source File: CustomizerLibraries.java From netbeans with Apache License 2.0 | 5 votes |
private void initTableVisualProperties(JTable table) { //table.setGridColor(jTableCpC.getBackground()); table.setRowHeight(jTableCpC.getRowHeight() + 4); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setIntercellSpacing(new java.awt.Dimension(0, 0)); // set the color of the table's JViewport table.getParent().setBackground(table.getBackground()); table.setShowHorizontalLines(false); table.setShowVerticalLines(false); TableColumn column = table.getColumnModel().getColumn(1); JTableHeader header = table.getTableHeader(); column.setMaxWidth(24 + SwingUtilities.computeStringWidth(header.getFontMetrics(header.getFont()), String.valueOf(column.getHeaderValue()))); header.setReorderingAllowed(false); }
Example 13
Source File: DiagnosticsForThreads.java From osp with GNU General Public License v3.0 | 5 votes |
public DiagnosticsForThreads() { JTable table = new JTable(tableModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); // code added Feb 2014 by Doug Brown FontSizer.setFonts(table, FontSizer.getLevel()); Font font = table.getFont(); table.setRowHeight(font.getSize()+4); table.getTableHeader().setFont(font); // end added code TableColumnModel colModel = table.getColumnModel(); int numColumns = colModel.getColumnCount(); for (int i = 0; i < numColumns - 1; i++) { TableColumn col = colModel.getColumn(i); col.sizeWidthToFit(); col.setPreferredWidth(col.getWidth() + 5); col.setMaxWidth(col.getWidth() + 5); } JScrollPane sp = new JScrollPane(table); setLayout(new BorderLayout()); add(sp, BorderLayout.CENTER); }
Example 14
Source File: CommunityDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void createRanksPanel(WorldObject playerCharacter, World world, int infoPanelWidth, int infoPanelHeight, JPanel infoPanel) { JPanel ranksPanel = JPanelFactory.createJPanel("Player Character Ranks"); ranksPanel.setLayout(null); ranksPanel.setBounds(510, 13, infoPanelWidth + 5, infoPanelHeight); infoPanel.add(ranksPanel, RANKS_KEY); OrganizationsModel worldModel = new OrganizationsModel(playerCharacter, world); JTable organizationsTable = JTableFactory.createJTable(worldModel); organizationsTable.setRowHeight(30); JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(organizationsTable); scrollPane.setBounds(15, 30, 525, 420); ranksPanel.add(scrollPane); SwingUtils.makeTransparant(organizationsTable, scrollPane); }
Example 15
Source File: TableEditor.java From jdal with Apache License 2.0 | 5 votes |
/** * Creates a new Box with table and actions buttons * @return a new Box */ protected Container createTablePanel() { table = new JTable(tableModel, tableModel.getTableColumnModel()); table.setRowHeight(22); table.setAutoCreateRowSorter(true); tableModel.addTableModelListener(this); JScrollPane scroll = new JScrollPane(table); scroll.setAlignmentX(Container.LEFT_ALIGNMENT); Box box = Box.createVerticalBox(); JButton addButton = new JButton(new AddAction()); JButton deleteButton = new JButton(new DeleteAction()); JButton saveButton = new JButton(new SaveAction()); JButton refreshButton = new JButton(new RefreshAction()); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(addButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(deleteButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(saveButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(refreshButton); buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT); buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25)); box.add(buttonBox); box.add(Box.createVerticalStrut(5)); box.add(scroll); return box; }
Example 16
Source File: EquipmentModels.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void actionPerformed(ActionEvent e) { EquipmentSetFacade equipSet = character.getEquipmentSetRef().get(); List<EquipNode> paths = getSelectedEquipmentSetNodes(); if (!paths.isEmpty()) { Object[][] data = new Object[paths.size()][3]; for (int i = 0; i < paths.size(); i++) { EquipNode path = paths.get(i); data[i][0] = path.getEquipment(); data[i][1] = equipSet.getQuantity(path); } Object[] columns = {LanguageBundle.getString("in_equipItem"), //$NON-NLS-1$ LanguageBundle.getString("in_equipQuantityAbbrev"), //$NON-NLS-1$ }; DefaultTableModel tableModel = new DefaultTableModel(data, columns) { @Override public Class<?> getColumnClass(int columnIndex) { if (columnIndex == 1) { return Integer.class; } return Object.class; } @Override public boolean isCellEditable(int row, int column) { return column != 0; } }; JTable table = new JTable(tableModel); table.setFocusable(false); table.setCellSelectionEnabled(false); table.setDefaultRenderer(Integer.class, new TableCellUtilities.SpinnerRenderer()); table.setDefaultEditor(Integer.class, new SpinnerEditor(equipSet.getEquippedItems())); table.setRowHeight(22); table.getColumnModel().getColumn(0).setPreferredWidth(140); table.getColumnModel().getColumn(1).setPreferredWidth(50); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); JScrollPane pane = EquipmentModels.prepareScrollPane(table); JPanel panel = new JPanel(new BorderLayout()); JLabel help = new JLabel(LanguageBundle.getString("in_equipSelectUnequipQty")); //$NON-NLS-1$ panel.add(help, BorderLayout.NORTH); panel.add(pane, BorderLayout.CENTER); int res = JOptionPane.showConfirmDialog(JOptionPane.getFrameForComponent(equipmentTable), panel, LanguageBundle.getString("in_equipUnequipSel"), //$NON-NLS-1$ JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (res == JOptionPane.OK_OPTION) { for (int i = 0; i < paths.size(); i++) { equipSet.removeEquipment(paths.get(i), (Integer) tableModel.getValueAt(i, 1)); } } } }
Example 17
Source File: ActionProviderImpl.java From netbeans with Apache License 2.0 | 4 votes |
@Messages({ "# {0} - Command Display Name", "TIT_BuildParameters={0} Parameters" }) private static String askInputArgs(String command, String argLine) { Matcher m = INPUT_PROP_REGEXP.matcher(argLine); List<String> keys = new ArrayList<>(); List<String> defaults = new ArrayList<>(); while (m.find()) { keys.add(m.group(1)); defaults.add(m.group(3) != null ? m.group(3) : ""); } String ret = argLine; if (!keys.isEmpty()) { KeyValueTableModel kvModel = new KeyValueTableModel("input:", keys.toArray(new String[keys.size()]), defaults.toArray(new String[defaults.size()]) ); JPanel panel = new JPanel(new BorderLayout()); JTable table = new JTable(kvModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); //NOI18N table.setRowHeight(table.getRowHeight() * 3 / 2); panel.add(new JScrollPane(table), BorderLayout.CENTER); try { //This code might not work on every Look and Feel DefaultCellEditor defaultEditor = (DefaultCellEditor) table.getDefaultEditor(String.class); defaultEditor.setClickCountToStart(1); } catch (ClassCastException ex) { } DialogDescriptor dlg = new DialogDescriptor(panel, TIT_BuildParameters(command)); if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(dlg)) { ret = replaceTokens(argLine, kvModel.getProperties()); } else { //Mark Cancel is pressed, so build shall be aborted. ret = null; } } return ret; }
Example 18
Source File: TransactionsPanel.java From btdex with GNU General Public License v3.0 | 4 votes |
public TransactionsPanel() { super(new BorderLayout()); table = new JTable(model = new MyTableModel()); table.setRowHeight(table.getRowHeight()+10); table.setRowSelectionAllowed(false); table.getTableHeader().setReorderingAllowed(false); copyIcon = IconFontSwing.buildIcon(Icons.COPY, 12, table.getForeground()); expIcon = IconFontSwing.buildIcon(Icons.EXPLORER, 12, table.getForeground()); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); // Center header and all columns DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); centerRenderer.setHorizontalAlignment( JLabel.CENTER ); for (int i = 0; i < table.getColumnCount(); i++) { table.getColumnModel().getColumn(i).setCellRenderer( centerRenderer ); } JTableHeader jtableHeader = table.getTableHeader(); DefaultTableCellRenderer rend = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer(); rend.setHorizontalAlignment(JLabel.CENTER); jtableHeader.setDefaultRenderer(rend); table.setAutoCreateColumnsFromModel(false); table.getColumnModel().getColumn(COL_ID).setCellRenderer(OrderBook.BUTTON_RENDERER); table.getColumnModel().getColumn(COL_ID).setCellEditor(OrderBook.BUTTON_EDITOR); table.getColumnModel().getColumn(COL_ACCOUNT).setCellRenderer(OrderBook.BUTTON_RENDERER); table.getColumnModel().getColumn(COL_ACCOUNT).setCellEditor(OrderBook.BUTTON_EDITOR); // table.getColumnModel().getColumn(COL_ACCOUNT).setPreferredWidth(200); table.getColumnModel().getColumn(COL_ID).setPreferredWidth(200); table.getColumnModel().getColumn(COL_TIME).setPreferredWidth(120); statusLabel = new JLabel(" ", JLabel.RIGHT); statusLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); add(statusLabel, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); }
Example 19
Source File: TimeTableEditor.java From LGoodDatePicker with MIT License | 3 votes |
/** * zAdjustTableRowHeightIfNeeded, If needed, this will adjust the row height for all rows in the * supplied table to fit the minimum row height that is needed to display the time picker * component. * * If autoAdjustMinimumTableRowHeight is false, this will do nothing. If the row height of the * table is already greater than or equal to "minimumRowHeightInPixels", then this will do * nothing. */ private void zAdjustTableRowHeightIfNeeded(JTable table) { if (!autoAdjustMinimumTableRowHeight) { return; } if ((table.getRowHeight() < minimumRowHeightInPixels)) { table.setRowHeight(minimumRowHeightInPixels); } }
Example 20
Source File: MDefaultTableCellRenderer.java From javamelody with Apache License 2.0 | 3 votes |
/** * Ajustement de la hauteur de cette ligne en fonction de la taille du renderer (ex: la taille d'une icône ou d'un label html). * * @param table * JTable * @param component * Component * @param row * int */ protected void adjustRowHeight(final JTable table, final Component component, final int row) { // Ajustement de la hauteur de cette ligne en fonction de la taille du renderer final int cellHeight = table.getRowHeight(row); final int rendererHeight = component.getPreferredSize().height; if (cellHeight < rendererHeight - 4) { // dans le cas normal, cellHeight est à 16 et rendererHeight est à 20 table.setRowHeight(row, rendererHeight); } }