有人可以啓發我在Java?下面的代碼只是使用JOptionPane和更多的inputdialog框來獲取用戶數據。JOptionPane輸入對話框
概念: 第一種選擇是選擇交易,然後如果他們按下S,另一個輸入對話框顯示要求PIN,然後在PIN另一個輸入對話框顯示4個選項,例如提取,檢查餘額,存款和退出。
顯示另一個輸入對話框的過程是什麼,然後返回到上一個輸入對話框的過程是什麼?然後,如果輸入錯誤,然後返回到先前的輸入對話框,驗證用戶輸入以首先顯示消息對話框的過程是什麼?
import javax.swing.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
String myOptions = "S = Select Transaction\n"
+ "Q = Quit\n"
+ "Enter your choice";
String myPin = "Enter your PIN";
String Y = "Yes";
String N = "No";
String value = JOptionPane.showInputDialog(
null, myOptions, "Computerized Automatic Teller Machine", 1);
if (value.equals("S")) {
JOptionPane.showInputDialog(
null, myPin, "Computerized Automatic Teller Machine", 1);
} else if (value.equals("Q")) {
JOptionPane.showMessageDialog(
null, "Are you sure you want to exit?",
"Computerized Automatic Teller Machine", 1);
} else {
JOptionPane.showMessageDialog(
null, "Please the correct letter!",
"Computerized Automatic Teller Machine", 1);
JOptionPane.showInputDialog(null, myOptions,
"Computerized Automatic Teller Machine", 1);
}
}
}//end of class
嗨。感謝您的答覆。我想我理解你的代碼。我會嘗試它,並會讓你知道:) – keyframer
嗨,它的作品。我的下一個麻煩是PIN應該從數據庫中看。我如何在數據庫的表格中插入找到它的方法。以下是我從數據庫中讀取信息的其他課程。 – keyframer
public void getPersonInfo(int selID){ try { \t String msg =「」; \t String myQuery =「」; \t myQuery =「SELECT LastName,FirstName FROM」+ \t \t \t「tblPerson WHERE PersonID =」+ selID; \t Statement myCommand = con.createStatement(); \t ResultSet selRecord = myCommand.executeQuery(myQuery); \t selRecord。下一個(); \t msg =「ID」+「」+「Name \ n」; \t msg + = selID +「」+ selRecord.getString(1)+「」+ selRecord.getString(2); \t JOptionPane.showMessageDialog(null,msg); \t selRecord.close(); \t myCommand.close(); (例外e){ \t JOptionPane.showMessageDialog(null,e); \t \t} \t} \t } – keyframer