table.setDefaultRenderer(Double.class, new NumberCellRenderer());
/** * Default constructor - builds a renderer that right justifies the * contents of a table cell. */ public NumberCellRenderer() { super(); setHorizontalAlignment(SwingConstants.RIGHT); }
final boolean hasFocus, final int row, final int column) { setFont(null); final NumberFormat nf = NumberFormat.getNumberInstance(); if (value != null) { setText(nf.format(value)); setText(""); setBackground(table.getSelectionBackground()); setBackground(null);
final boolean hasFocus, final int row, final int column) { setFont(null); final NumberFormat nf = NumberFormat.getNumberInstance(); if (value != null) { setText(nf.format(value)); setText(""); setBackground(table.getSelectionBackground()); setBackground(null);
final boolean hasFocus, final int row, final int column) { setFont(null); final NumberFormat nf = NumberFormat.getNumberInstance(); if (value != null) { setText(nf.format(value)); setText(""); setBackground(table.getSelectionBackground()); setBackground(null);
/** * Creates a panel that contains a table based on the specified table model. * * @param model the table model to use when constructing the table. * * @return The panel. */ public static JPanel createTablePanel(final TableModel model) { final JPanel panel = new JPanel(new BorderLayout()); final JTable table = new JTable(model); for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++) { final TableColumn column = table.getColumnModel().getColumn(columnIndex); final Class c = model.getColumnClass(columnIndex); if (c.equals(Number.class)) { column.setCellRenderer(new NumberCellRenderer()); } } panel.add(new JScrollPane(table)); return panel; }
/** * Default constructor - builds a renderer that right justifies the * contents of a table cell. */ public NumberCellRenderer() { super(); setHorizontalAlignment(SwingConstants.RIGHT); }
/** * Creates a panel that contains a table based on the specified table model. * * @param model the table model to use when constructing the table. * * @return The panel. */ public static JPanel createTablePanel(final TableModel model) { final JPanel panel = new JPanel(new BorderLayout()); final JTable table = new JTable(model); for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++) { final TableColumn column = table.getColumnModel().getColumn(columnIndex); final Class c = model.getColumnClass(columnIndex); if (c.equals(Number.class)) { column.setCellRenderer(new NumberCellRenderer()); } } panel.add(new JScrollPane(table)); return panel; }
/** * Default constructor - builds a renderer that right justifies the * contents of a table cell. */ public NumberCellRenderer() { super(); setHorizontalAlignment(SwingConstants.RIGHT); }
/** * Creates a panel that contains a table based on the specified table model. * * @param model the table model to use when constructing the table. * * @return The panel. */ public static JPanel createTablePanel(final TableModel model) { final JPanel panel = new JPanel(new BorderLayout()); final JTable table = new JTable(model); for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++) { final TableColumn column = table.getColumnModel().getColumn(columnIndex); final Class c = model.getColumnClass(columnIndex); if (c.equals(Number.class)) { column.setCellRenderer(new NumberCellRenderer()); } } panel.add(new JScrollPane(table)); return panel; }