Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Renderer extends JPanel implements TableCellRenderer {
- public Renderer() {
- super();
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- }
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus, int row,
- int column) {
- if (value == null)
- return null;
- JLabel label = new JLabel(value.toString());
- label.setAlignmentX(Component.CENTER_ALIGNMENT);
- add(label);
- if (isSelected) {
- setBackground(table.getSelectionBackground());
- setForeground(table.getSelectionForeground());
- } else {
- setBackground(table.getBackground());
- setForeground(table.getForeground());
- }
- return this;
- }
- }
Add Comment
Please, Sign In to add comment