table.setDefaultRenderer(Double.class, new NumberCellRenderer());
/** * 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; }
/** * 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; }
/** * 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; }