Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Close window without confirm (I.E only) window.opener=null; window.open('','_self'); window.close(); focus on validating function focusOnInvalidControl() {     for (var i = 0; i < Page_Validators.length; i++) {         if (!Page_Validators[i].isvalid) {     ...
Blog Archive
Stats
Default checkbox renderer in JTabel
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

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

public class CheckBoxCellinTable extends JFrame {

    JTable table;

    public CheckBoxCellinTable() {

        this.setLayout(new BorderLayout());
        this.initTable();

        setSize(400, 300);
        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((sc.width - getWidth()) / 2, (sc.height - getHeight()) / 2);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }

    void initTable() {
        Object[] columnNames = { "First Name", "Last Name", "Married" };
        Object[][] data = { { "Harry", "Smith", true }, { "Sally", "Jones", false }, { "Bob", "Clark", true }, { "Eric", "Burke", true } };

        DefaultTableModel model = new DefaultTableModel(data, columnNames) {
            @Override
            public boolean isCellEditable(int row, int column) {
                return column == 2;
            }

            @Override
            public Class<?> getColumnClass(int columnIndex) {
                return columnIndex == 2 ? Boolean.class : super.getColumnClass(columnIndex);
            }
        };
        table = new JTable(model);

        this.add(new JScrollPane(table), BorderLayout.CENTER);
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new CheckBoxCellinTable();
    }

}