Java Code Examples for javax.swing.JTable#setGridColor()
The following examples show how to use
javax.swing.JTable#setGridColor() .
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: 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 2
Source File: TableViewPagePanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override protected void initComponents() { final AbstractButton switchToChartButton = ToolButtonFactory.createButton(iconForSwitchToChartButton, false); switchToChartButton.setToolTipText("Switch to Chart View"); switchToChartButton.setName("switchToChartButton"); switchToChartButton.setEnabled(hasAlternativeView()); switchToChartButton.addActionListener(e -> showAlternativeView()); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.add(switchToChartButton, BorderLayout.NORTH); buttonPanel.add(getHelpButton(), BorderLayout.SOUTH); add(buttonPanel, BorderLayout.EAST); table = new JTable(); table.removeEditor(); table.setGridColor(Color.LIGHT_GRAY.brighter()); table.addMouseListener(new PagePanel.PopupHandler()); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final JScrollPane scrollPane = new JScrollPane(table); add(scrollPane, BorderLayout.CENTER); }
Example 3
Source File: DrawGridLinesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkTableGridLines() { TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public Object getValueAt(int row, int col) { return " "; } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); JTable table = new JTable(dataModel); table.setSize(WIDTH, HEIGHT); table.setDefaultRenderer(Object.class, r); table.setGridColor(GRID_COLOR); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setBackground(TABLE_BACKGROUND_COLOR); checkTableGridLines(table); }
Example 4
Source File: DrawGridLInesTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkTableGridLines() { TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public Object getValueAt(int row, int col) { return " "; } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); JTable table = new JTable(dataModel); table.setSize(WIDTH, HEIGHT); table.setDefaultRenderer(Object.class, r); table.setGridColor(GRID_COLOR); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setBackground(TABLE_BACKGROUND_COLOR); checkTableGridLines(table); }