Posted Wednesday, October 24, 2007 @ 10:56:19
Hi, i have a table (oracle) with a checkbox
CREATE TABLE atest (
id VARCHAR2(9) NOT NULL,
checkbox VARCHAR2(1) NOT NULL
)
insert into atest(id,checkbox) values('1','O');
insert into atest(id,checkbox) values('2','O');
insert into atest(id,checkbox) values('3','O');
if you want to deselect all checkbox BEGINNING with the first line, then the second checkbox will not be "deselected" after a refresh.
i have at the beginning:
1 O
2 O
3 O
with my mouse i put all checkbox out (beginning with first line), i have
1 N
2 N
3 N
but when i refresh i have
1 N
2 O
3 N
a bug ...
here's the code to try:
import java.awt.*;
import java.awt.event.*;
import java.sql.SQLException;
import java.util.Hashtable;
import javax.swing.*;
import javax.swing.table.*;
import quick.dbtable.Column;
public class Main extends JFrame
{
public Main()
{
setSize(300,200);
setVisible(true);
quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();
getContentPane().add(dBTable1);
dBTable1.setDatabaseDriver("oracle.jdbc.driver.OracleDriver");
dBTable1.setJdbcUrl("jdbc:oracle:thin:demo/mypass@127.0.0.1:1521:ORCL");
dBTable1.setSelectSql("select id,checkbox from atest");
dBTable1.addUpdateSql("update atest set checkbox =? where id =?", "2,1");
dBTable1.addInsertSql("insert into atest ( id, checkbox) values (?,?)", "1,2");
dBTable1.addDeleteSql("delete from atest where id = ?", "1");
dBTable1.createControlPanel();
try
{
dBTable1.connectDatabase();
dBTable1.refresh();
Column colonne = dBTable1.getColumn(1);
colonne.setPreferredWidth(50);
Hashtable h = new Hashtable();
h.put("O", new Boolean(true));
h.put("N", new Boolean(false));
dBTable1.setCellComponent(colonne, Column.CHECKBOX_CELL, h);
dBTable1.refresh();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
Main myframe = new Main();
}
}