Code around in a file to add joptionpane

Assignment Help Basic Computer Science
Reference no: EM13161525

 

It requires us to change some code around in a file to add joptionpane dialog boxes in instead of the fields already there. The following is the exact wording of the assignment:

Look through the source code for the Flora. java file. Insert comment marks (//) at the beginning of all lines involving any of the message boxes, except for the MessageBox declaration statements. Directly underneath the lines that are commented out, insert new code to generate JOptionPane dialog boxes that replace the message boxes. Use the same titles, prompts, and buttons. Do not forget to import the necessary Swing packages.

I am having trouble figuring out how to add a JOptionPane box in. I imported the swing for the joptionpane but I need assistance setting it up for the boxes

String code;
  if (arg == "New Sticker")
     code = "N";
  else
     code = "R";

  if (
        (vin.getText().compareTo("")<1)       ||
        (year.getText().compareTo("")<1)      ||
        (make.getText().compareTo("")<1)      ||
        (model.getText().compareTo("")<1)     ||
        (firstName.getText().compareTo("")<1) ||
        (lastName.getText().compareTo("")<1)  ||
        (address.getText().compareTo("")<1)
     )
  {

     errorBox = new MessageBox(this, "Data Entry Error", "You must complete all fields.");
     errorBox.setVisible(true);
  }
  else
  {
  try
  {
     output.writeUTF(code);
     output.writeUTF(vin.getText());
     output.writeUTF(year.getText());
     output.writeUTF(make.getText());
     output.writeUTF(model.getText());
     output.writeUTF(firstName.getText());
     output.writeUTF(lastName.getText());
     output.writeUTF(address.getText());

         savedBox = new MessageBox(this, "Data Submitted", "The vehicle information has been saved.");
         savedBox.setVisible(true);
      }
      catch(IOException c)
      {
         System.exit(1);
      }
      clearFields();
      }
   }

   public void clearFields()
   {
      //Clear fields and reset the focus
      vin.setText("");
      year.setText("");
      make.setText("");
      model.setText("");
      firstName.setText("");
      lastName.setText("");
      address.setText("");
      vin.requestFocus();
    }
}

 

 

Reference no: EM13161525

What is meant by rational expectations

Would believers in rational expectations want to shorten a recession by expanding aggregate demand? Would they want to fight inflation by reducing aggregate demand? Relate t

What is the ranking of the algorithms

To perform the tests, create a randomly generated array of 1,000 elements. What is the ranking of the algorithms? What happens when you increase the array size to 10,000 ele

Compare and contrast twisted pair cable

Compare and contrast twisted pair cable, coaxial cable, fiber-optics, and wireless for this application. You should create a table or flow chart which would facilitate choos

Develop a java applet

This method should be called once when the applet begins execution and each time the user answers the question correctly. All drawing on the applet should be performed by th

Cubic maximum subsequence sum algorithm performs

The inner loop of the cubic maximum subsequence sum algorithm performs N(N+1)(N+2)/6 iterations of the innermost code. The quadratic version performs N(N + 1)/2 iterations.

Use the graphics class to draw a line between the points

Given a graphics object g, write a few lines of code to have that graphics object draw a magenta circle (not filled in) that has a diameter of 200 pixels. What does invoking

Managing the contractor-customer relationship

Discuss the ethical issues that can arise in contracting. Analyze and discuss the strengths and weaknesses of the dispute process using the concepts discussed in the text. D

Describe the five essential features of the queuing system

On the basis of your experience and the description of Thrifty's operations, describe the five essential features of the queuing systems at the customer counter, the garage,

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd