0

我编写了一个从数据库读取数据的程序,最后一列是布尔值,0 表示假,1 表示真,但我想将该列显示为复选框。我现在将粘贴我的代码:private void update_table(){

    String sql = "select dailies.id as 'م', customers.name as' العميل',ddate as' التاريخ' ,cars.name as' السيارة',material.name as' المادة',quantity as'عدد',dailytypes.name as' الوحدة',unitprice as' سعر الوحدة',discount as' الخصم',(unitprice*quantity - discount) as' الإجمالي',notes as' ملاحظات', paid as'تم السداد' from dailies,customers,cars,material,dailytypes where ddate=? and dailies.customer = customers.id and dailies.car = cars.id and dailies.material = material.id and dailies.type = dailytypes.id  order by ddate";
    try{
        pst = conn.prepareStatement(sql);
        //JOptionPane.showMessageDialog(null, currentdate());
        pst.setString(1, currentdate());
        rs = pst.executeQuery();
        tbldailies.setModel(DbUtils.resultSetToTableModel(rs));
        //tbldailies.addColumn();
    }catch (Exception ex){
        JOptionPane.showMessageDialog(null, ex);
    } finally{
        try{

            rs.close();
            rs1.close();
            pst.close();

        }
        catch(Exception e){
            e.printStackTrace();
        }
    }

}

4

2 回答 2

0

Java 教程中的“如何使用表”包含许多这样的示例: http: //docs.oracle.com/javase/tutorial/uiswing/components/table.html

于 2013-07-03T02:42:03.513 回答
0

在@Keith指向的链接:

public class NewbieTableModel extends AbstractTableModel {
     // ...
     public Class getColumnClass(int c) {
           return getValueAt(0, c).getClass();
     }
     // ...
}

希望有帮助...

于 2013-07-03T03:01:42.833 回答