Need java help with JOptionPane dialog boxes?
-
I got this far in my assignment but the next step is extremely confusing. My code is below. The next step is... Look through the source code for the Flora.java file. (the code below is Flora.java). 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. import java.io.*; import java.awt.*; import java.awt.event.*; public class Flora extends Frame implements ActionListener { MessageBox savedBox; MessageBox errorBox; DataOutputStream output; //Construct components Panel dataFields = new Panel(); Panel firstRow = new Panel(); Panel secondRow = new Panel(); Panel thirdRow = new Panel(); Panel fourthRow = new Panel(); Panel fifthRow = new Panel(); Panel sixthRow = new Panel(); Panel buttonArea= new Panel(); Button newSticker = new Button("New Sticker"); Button renewal = new Button("Renewal"); Label vinLabel = new Label("Enter Vehicle VIN number: "); TextField vin = new TextField(20); Label yearLabel = new Label("Year: "); TextField year = new TextField(4); Label makeLabel = new Label("Make: "); TextField make = new TextField(10); Label modelLabel = new Label("Model:"); TextField model = new TextField(10); Label firstNameLabel = new Label("Enter First Name: "); TextField firstName = new TextField(15); Label lastNameLabel = new Label("Enter Last Name:"); TextField lastName = new TextField(20); Label addressLabel = new Label("Enter Flora Address:"); TextField address = new TextField (35); public static void main(String[] args) { Flora window = new Flora(); window.setTitle("Flora City Stickers"); window.setSize(450, 250); window.setVisible(true); } public Flora() { //Set background and layout managers setBackground(Color.magenta); setLayout(new BorderLayout()); dataFields.setLayout(new GridLayout(6,1)); FlowLayout rowSetup = new FlowLayout(FlowLayout.LEFT,5,2); firstRow.setLayout(rowSetup); secondRow.setLayout(rowSetup); thirdRow.setLayout(rowSetup); fourthRow.setLayout(rowSetup); fifthRow.setLayout(rowSetup); sixthRow.setLayout(rowSetup); buttonArea.setLayout(new FlowLayout()); //Add fields to rows firstRow.add(vinLabel); firstRow.add(yearLabel); firstRow.add(makeLabel); firstRow.add(modelLabel); secondRow.add(vin); secondRow.add(year); secondRow.add(make); secondRow.add(model); thirdRow.add(firstNameLabel); thirdRow.add(lastNameLabel); fourthRow.add(firstName); fourthRow.add(lastName); fifthRow.add(addressLabel); sixthRow.add(address); //Add rows to panel dataFields.add(firstRow); dataFields.add(secondRow); dataFields.add(thirdRow); dataFields.add(fourthRow); dataFields.add(fifthRow); dataFields.add(sixthRow); //Add buttons to panel buttonArea.add(newSticker); buttonArea.add(renewal); //Add panels to frame add(dataFields, BorderLayout.NORTH); add(buttonArea, BorderLayout.SOUTH); //Add functionality to buttons newSticker.addActionListener(this); renewal.addActionListener(this); //Open the file try { output = new DataOutputStream(new FileOutputStream("Sticker.dat")); } catch(IOException c) { System.exit(1); } //Construct window listener addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); } public void actionPerformed(ActionEvent e) { String arg = e.getActionCommand(); 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) ) {
-
Answer:
This is a help forum btw and not a wholesale "post your homework and get it done for you" site. The documentation clearly indicates this isn't your code and is stub for your assignment. If you have a question, ask and we'll do our best to help you.
Chris Fota at Yahoo! Answers Visit the source
Related Q & A:
- I need desperate help.Best solution by Yahoo! Answers
- I need Ebay help.Best solution by Yahoo! Answers
- I need some help about yahoo answers.Best solution by Yahoo! Answers
- Need some help about Suzuki bike?Best solution by Yahoo! Answers
- Msn messenger help need some help?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.