इसलिए इस प्रोजेक्ट में मैंने और मेरे पार्टनर ने GUI बनाया। मुझे e.txt
नाम की टेक्स्ट फ़ाइल से चेक करके ईमेल और पासवर्ड को सत्यापित करने की आवश्यकता है। GUI लॉगिन करें मैं सिर्फ यह जानना चाहता था कि नीचे दिया गया कोड कुछ हद तक सही है या नहीं। एक बार जब मैंने इसे चलाने की कोशिश की तो मैंने कुछ त्रुटियों में भाग लेना शुरू कर दिया। मैंने एक और बदलाव किया है कि मैंने टेक्स्टफील्ड आईडी बनाई है। हमारे पास वहां टेक्स्टफील्ड थे, वहां कोई आईडी नहीं थी। अब जब मैंने उन्हें आईडी बना लिया है और परिवर्तनों को सहेज लिया है, तो समस्याएं शुरू हो गई हैं। जब से मैंने login.fxml में परिवर्तनों को सहेजा है, प्रोग्राम अब gui को पॉप अप करने की अनुमति नहीं देता है। सिंटैक्स के अनुसार, क्या मान्य ईमेलएंडपासवर्ड फ़ंक्शन में कुछ गड़बड़ है?
package cais240courseproj;
public class CAIS240CourseProj extends Application {
@Override
public void start(Stage stage) throws Exception {
//netbeans has directed me to this as the problem that isn't allowing
//the program to run
Parent root = FXMLLoader.load(getClass().getResource("Login.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
stage.setResizable(false);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
public class FXMLDocumentController implements Initializable {
boolean validAccount;
@FXML
private Label label;
@FXML
private ImageView iv;
@FXML
private AnchorPane rootLogin;
@FXML
private Button registerBtn;
@FXML
private Button EmailTextField;
@FXML
private Button passwordTextField;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
label.setText("Hello World!");
}
@FXML
private void loadRegister(ActionEvent event) throws IOException {
Parent registerPane = FXMLLoader.load(getClass().getResource("Register.fxml"));
//Make sure the textfields aren't empty
if( (!EmailTextField.getText().isEmpty() ) && ( !passwordTextField.getText().isEmpty() ) )
//take the user input (email and password) and compare them with registered
//account info
validatePassAndEmail(EmailTextField.getText(), passwordTextField.getText());
Scene tableViewScene = new Scene(registerPane);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.show();
}
private void validatePassAndEmail(String email, String password) throws IOException{
boolean sameEmail = false, samePassword = false;
Scanner scan = new Scanner(new File("e.txt"));
//comparing and checking to see if the user input is a registered account
while( (sameEmail == false) && (samePassword == false) ){
while (scan.hasNextLine()) {
if( sameEmail == false && email.equals(scan.next()))
sameEmail = true;
if(samePassword == false && password.equals(scan.next()))
samePassword = true;
//if the scanner has reached the end with no matches
if(scan.next().equals(""))
break;
}
}
if( sameEmail == true && samePassword == true )
validAccount = true;
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
1 उत्तर
क्या EmailTextField
और passwordTextField
में TextField
टाइप होना चाहिए? बटन नोड में विधि नहीं है .getText()
@FXML
private TextField EmailTextField;
@FXML
private TextField passwordTextField;
संबंधित सवाल
नए सवाल
validation
सत्यापन का उपयोग डेटा की जांच करने के लिए किया जाता है ताकि यह सुनिश्चित हो सके कि इसके लिए जो भी आवश्यक विनिर्देश निर्धारित हैं वह फिट बैठता है। आमतौर पर सत्यापन का उपयोग इनपुट डेटा की जांच करने और भंडारण से पहले डेटा का सत्यापन करने में किया जाता है।