Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java验证GUI Netbeans_Java_Validation_User Interface_Netbeans - Fatal编程技术网

Java验证GUI Netbeans

Java验证GUI Netbeans,java,validation,user-interface,netbeans,Java,Validation,User Interface,Netbeans,您好,我有一个用于java的GUI Netbeans项目,当我单击submit时,它会检查文本字段的验证 这是我的密码 private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) { //VALIDATIONS---------------------------------------------------------

您好,我有一个用于java的GUI Netbeans项目,当我单击submit时,它会检查文本字段的验证

这是我的密码

private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {                                          


    //VALIDATIONS-----------------------------------------------------------
    if(txtName.getText().trim().equals(""))
    {
        JOptionPane.showMessageDialog(null, "Must have name");
        jlblNameVer.setVisible(true);

    }
    else 
    {
        jlblNameVer.setVisible(false);
    }

    //ID VERIFICATION
    if (txtIdNumber.getText().trim().equals(""))
   {
        JOptionPane.showMessageDialog(null, "Photo Id must not be emplty");
   }

    //EMAIL VALIDATION
    if(txtEmail==null ||txtEmail.getText().length() < 10|| txtEmail.getText()== null ||!(txtEmail.getText().trim().contains("@") && txtEmail.getText().trim().contains(".")))
    {
         JOptionPane.showMessageDialog(null, "Invalid Email");
     }

    //Phone Number Validation
     if(txtPhoneNum.getText().length() < 10)
    {
        JOptionPane.showMessageDialog(null, "Must atleast 10 characters");
    }

     //COMBOBOX VALIDATIONS
     if(cmbStayDuration.getSelectedIndex() == -1)
    {
        JOptionPane.showMessageDialog(null, "Please select stay duration");
    }

     //Photo ID
      if(cmbPhotoId.getSelectedIndex() == -1)
    {
        JOptionPane.showMessageDialog(null, "Please select Photo ID type");
    }

    String roomType = cmbRoomType.getSelectedItem().toString();
    String roomNumber = cmbRoomNumber.getSelectedItem().toString();
    String checkin = ftxtCheckinDate.getText();
    String checkout = txtCheckOut.getText();
    String Name = txtName.getText();
    String IdType = cmbPhotoId.getSelectedItem().toString().trim();
    String IdNumber = txtIdNumber.getText();
    String Phone = txtPhoneNum.getText();
    String email = txtEmail.getText().trim();


    JOptionPane.showMessageDialog(null,roomType,roomNumber,checkin,checkout,Name,IdType,IdNumber,Phone,email);

NOT WORKING (optionpane with variables)^^^^^^^^


}    
我不想确保,如果所有这些都是正确的,那么该程序有一个弹出窗口,其中显示了所有输入到表单中的变量

这是一张GUI的图片 不接受这么多参数。您应该连接字符串,而不是单独传递它们

尝试:

不接受这么多参数。您应该连接字符串,而不是单独传递它们

尝试:


可以将数组传递到选项窗格。阵列中的每个对象将显示在不同的行上:

String[] messages = new String[3];
messages[0] = "Message line1";
messages[1] = "Message line1";
messages[2] = "Message line1";

JOptionPane.showMessageDialog(
    null, // parent frame
    messages,
    "Multiline Message",
    JOptionPane.INFORMATION_MESSAGE);

阅读上Swing教程中的部分,了解JOptionPane的更多示例和功能。

您可以将数组传递到选项窗格。阵列中的每个对象将显示在不同的行上:

String[] messages = new String[3];
messages[0] = "Message line1";
messages[1] = "Message line1";
messages[2] = "Message line1";

JOptionPane.showMessageDialog(
    null, // parent frame
    messages,
    "Multiline Message",
    JOptionPane.INFORMATION_MESSAGE);
阅读上Swing教程中的部分,以了解JOptionPane的更多示例和功能