Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class Main {
    public static void main(String[] args) throws Exception {
        DefaultTableModel model = new DefaultTableModel(null, new String[] { "CheckMe", "Value" }) {
            public Class getColumnClass(int c) {
                switch (c) {
                case 0:
                    return Boolean.class;
                default:
                    return String.class;
                }
            }
        };
        JTable table = new JTable(model);
        JFrame frame = new JFrame("CheckBox Test");
        frame.add(table);
        model.addRow(new Object[] { true, "This is true" });
        model.addRow(new Object[] { false, "This is false" });
        frame.pack();
        frame.validate();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}