Dear all,
I'm sorry to ask you again.
This code is my jTable that I copy from my Netbeans source code.
tblGroupAnggaran.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null}
},
new String [] {
"Kode group", "Nama group"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
tblGroupAnggaran.setColumnSelectionAllowed(true);
jScrollPane1.setViewportView(tblGroupAnggaran);
tblGroupAnggaran.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
I have tried this code :
void isiTable(String kataKunci)
{
String SQL = "";
SQL = "SELECT * FROM mastergroupanggaran ";
if(!kataKunci.equals(""))
{
if(cmbSearch.getSelectedIndex()==0)
{
SQL += " WHERE kodegroupanggaran LIKE '%" + kataKunci + "%'";
}
else
{
SQL += " WHERE namagroupanggaran LIKE '%" + kataKunci + "%'";
}
}
SQL += " ORDER BY kodegroupanggaran";
deleteTableContents();
try{
Koneksi getCn = new Koneksi();
Connection cn = getCn.getConnection();
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery(SQL);
while(rs.next())
{
String Kode = rs.getString(1);
String Nama = rs.getString(2);
String[] data = {"",Kode,Nama}; tblGroupAnggaran.addRow(data);
}
}
catch(SQLException e)
{
}
}
But Netbeans does not recogizne that statement (in bold format), whereas if we see in Java manual book, it works.
Thanks for your advance,
Kusno