Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:01:51+00:00 2026-05-31T06:01:51+00:00

I have a Form with a few textfields and a save button. When the

  • 0

I have a Form with a few textfields and a save button.
When the buttton is pressed, it should be checked whether certain textfields are empty, and if those are empty, then an error message should be displayed, else whatever job needed should be performed. i have written the code for that, but whether the fields are empty or not, it performs the main tasks. Could someone advise please? thanks

final JButton button = new JButton("Save");
button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
        if(textField_2.equals("") || textField_3.equals("") || textField_4.equals("") || textField_5.equals("") || textField_6.equals("") || textArea.equals("") || textField_7.equals("")) {
            JOptionPane.showMessageDialog(frmModifyBooking, "Please fill in all fields indicated with a star (*).");
        }
        else {
            try {
                String sql = "UPDATE vacation SET `StaffID` =?, `From` =?, `To` =?, `TotalDays` =?, `VacationType` =?, `Notes` =?, `Signature` =?, `Date` =? WHERE VacationID = ?";
                PreparedStatement prest = con.prepareStatement(sql);
                prest.setString(1, textField_1.getText());
                prest.setString(2, textField_2.getText());
                prest.setString(3, textField_3.getText());
                prest.setString(4, textField_4.getText());
                prest.setString(5, textField_5.getText());
                prest.setString(6, textArea.getText());
                prest.setString(7, textField_6.getText());
                prest.setString(8, textField_7.getText());
                prest.setString(9, txtAUniqueStudent.getText());
                prest.executeUpdate();
                JOptionPane.showMessageDialog(frmModifyBooking, "Record has been updated.");
            }
            catch (SQLException e) {
                //System.out.println("Record couldn't be added!");
                e.printStackTrace();
                JOptionPane.showMessageDialog(frmModifyBooking, "Record couldn't be updated. Please try again.");
            }
        }
    }
});
button.setBounds(280, 402, 89, 23);
panel_1.add(button);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:01:52+00:00Added an answer on May 31, 2026 at 6:01 am

    Did you mean:

    textField_2.getText().equals("") etc.
    

    which you could also write:

    textField_2.getText().isEmpty() etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form with few buttons and I want to know what button is
I have a form with a few buttons which execute code when pressed like
HI I have a form with a few buttons. Each button runs a few
I have a form with a few fields, one of which should be updated
i have few textfields in my php form. i want to handle the keypress
i have a form with few fileds and a submit button... when i click
I have a form with a few textareas and selectors and the submit button
I have problem with TinyMCE editor. I have form with few text fields and
I have a form with a few input fields. When a user clicks on
I have a form that has a few similar controls and the parent contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.