Watch for yourself:
import javax.swing.*;
import javax.swing.table.*;
public class BooleanTable implements Runnable {
public static void main(String[] args) throws Exception {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
SwingUtilities.invokeLater(new BooleanTable());
}
@Override
public void run() {
JTable table = new JTable(new Model());
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(new JScrollPane(table));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
static class Model extends AbstractTableModel {
@Override
public int getColumnCount() { return 2; }
@Override
public String getColumnName(int col) { return getColumnClass(col).getSimpleName(); }
@Override
public Class<?> getColumnClass(int col) { return col==0 ? Number.class : Boolean.class; }
@Override
public int getRowCount() { return 100; }
@Override
public Object getValueAt(int row, int col) { return col==0 ? row : row%3==0; }
}
}
Feature or Bug?