我正在研究我的第一个基于桌面的Java项目.我实际上有两个问题
1)如何对JOptionPane.showMessageDialog的OK按钮执行操作.我想在单击确定时导航到新的Jframe说x.java.
2)我有一个名为user的表.此表有8列userid(主键),名称,密码,emailid,dob,mobileno,city,date.必须从Jframe x中获取四个列条目,而从其他Jframe y中获取四个列条目.
我写了以下代码
对于第X帧
PreparedStatement stm = con.prepareStatement("insert into user
(userrid,name,password,emailid))values (?,?,?) ");
stm.setString(1,id); // id is a public variable
stm.setString(2,name);
stm.setString(3,ps);
stm.setString(4,email);
stm.executeUpdate();
对于帧Y.(userid是主键)
public class Y extends javax.swing.JFrame
{
X o = new X(); // to access id variable from frame X
}
PreparedStatement stm = con.prepareStatement(" update user set dob ='? ',mobileno
='?',city='?',date='?' where userid= 'o.id' ");
它不断抛出上述SQL查询的异常
最佳答案
1) How to perform action on OK button of JOptionPane.showMessageDialog.I want to navigate to a new Jframe say x.java on clicking ok.
int input = JOptionPane.showOptionDialog(null,"Hello World","The title",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE,null,null);
if(input == JOptionPane.OK_OPTION)
{
// do something
}