|
String a = myselect.getSelectedItem().toString();
String b = con.getText();
SafeInfo ss = new SafeInfo();
MyTabelModel m;
if (!a.equals("all information")) {
if (a.equals("Insurance Number")) {
int flag = 0;
char c;
for (int i = 0; i <b.length(); i++) {
c = b.charAt(i);
if (Character.isLetter(c)) {
flag = 1;
}
}
if (flag == 1) {
javax.swing.JOptionPane.showMessageDialog(null,
"<html><font color=red>Please enter a number!</font></html>",
"System Message", JOptionPane.ERROR_MESSAGE);
m = null;
this.con.setText("");
this.con.requestFocus();
} else {
//My query statement m = ss.getMyTabelModel("select * from SafeInfo where "+ a +
"like'%" + b + "%'");
}
} else {
//My query statement is the error reported here m = ss.getMyTabelModel("select * from SafeInfo where "+ a +
"like'%" + b + "%'");
}
} else {
m = ss.getMyTabelModel("select * from SafeInfo");
}
if (m != null) {
this.useTabel.setModel(m);
} else {
javax.swing.JOptionPane.showMessageDialog(null,
"<html><font color=red>There is no data you are looking for, please check carefully and then check</font></html>",
"System Message", JOptionPane.ERROR_MESSAGE);
this.con.setText("");
this.con.requestFocus();
}
}
public void myselect_actionPerformed(ActionEvent e) {
if (this.myselect.getSelectedItem().toString().equals("all information")) {
this.con.setText("");
this.con.setEditable(false);
} else {
this.con.setEditable(true);
} |
|