0
我需要有一個更新按鈕來更新已編輯的文本字段並將其保存到數據庫。我已經創建了該按鈕,但不知道如何使其更新編輯的文本字段並自動更新數據庫。Java簡單更新按鈕
這是我的代碼:
private JButton getJButtonUpdate() {
int centralize_width = (screenSize.width/2) - 150;
if (jButton_Update == null) {
jButton_Update = new JButton();
jButton_Update.setText("Update");
jButton_Update.setLocation(new Point(centralize_width, 300));
jButton_Update.setSize(new Dimension(150, 30));
jButton_Update.setHorizontalTextPosition(SwingConstants.CENTER);
jButton_Update.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("Moving on to Existing Panel!");
if(Selected != null) {
JPanel panel = new Case_Details(frame, Analyst_ID, Selected);
frame.getContentPane().removeAll();
frame.getContentPane().add(panel);
frame.getContentPane().validate();
frame.getContentPane().repaint();
}
}
});
}
return jButton_Update;
}
您與數據庫有連接。知道如何使用JDBC? – 2012-02-03 09:02:25