i am trying to get the input the info so when the choices are chosen and submit is clicked the info is seen for the flower order but getting errors. if you read it you would probably get what i am trying to say but how to get it without the errors.

import javax.swing.*;
//import javax.swing.AbstractButton;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class floralOrderGUI {

    JButton SubmitButton = new JButton("Submit");
    private JButton Submit;
   private SubmitButtonHandler sHandler;
	public static void main(String[] args) {

            new floralOrderGUI();
		//system.exit(Q);
	}

	public floralOrderGUI(){
		JFrame mainFrame = new JFrame ("mobileOrders");
		mainFrame.setSize (300, 300);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainFrame.setLayout(new GridLayout (0,2));

	//create components for the window
		JLabel mobileOrdersInputLabel = new JLabel("Menu Choice", SwingConstants.RIGHT);
		JLabel floralOrdersInputLabel = new JLabel("Floral Orders", SwingConstants.RIGHT);


		JTextField numInput = new JTextField();
		numInput.setBackground(new Color (255, 199, 64));
		numInput.setForeground(new Color(176, 165, 50));
		numInput.setBackground(new Color(184, 120, 85));
		numInput.setForeground(new Color(184, 120, 85));
		JComboBox menuChoice = new JComboBox();
		JComboBox paymentOption = new JComboBox();
		JComboBox dFlowerOption = new JComboBox();
                JComboBox deliveryOption = new JComboBox();
		numInput.setBackground(new Color (255, 199, 64));
		numInput.setForeground(new Color(184, 120, 85));


		String floralOption[] ={ "Cut Flowers = $15.00","Floral Arrangemen = $25.00t","Coursages = 10.00","None"};

		for (int i= 0; i<=3; i++)
		     menuChoice.addItem(floralOption[i]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();

		String dominantFlower[] = { "Roses = $5.00", "Daisies", "Chrysanthemums", "Irises"};

		for (int j= 0; j<=3; j++)
			dFlowerOption.addItem(dominantFlower[j]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();




		String payment[] ={ "Cash", "Cheque", "Credit Card"};

                for (int k= 0; k<=2; k++)
                        paymentOption.addItem(payment[k]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();


                String dOption[]= { "Drop Off = $10.00", "Pick Up"};

                for (int L= 0; L<=1; L++)
                    deliveryOption.addItem(dOption[L]);

                numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		Container c = mainFrame.getContentPane();

                //create submit button
                Submit = new JButton("Submit");
                sHandler = new SubmitButtonHandler();
                Submit.addActionListener(sHandler);

		//add element to the window container

		c.add(mobileOrdersInputLabel);
		c.add(floralOrdersInputLabel);
                c.add(SubmitButton);
		c.add(menuChoice);
                c.add(dFlowerOption);
                c.add(paymentOption);
                c.add(deliveryOption);
		mainFrame.setVisible(true);
               // c.setVisible(true);


	}

        private class SubmitButtonHandler implements ActionListener
        {
            public void actionPerformed(ActionEvent e)
            {
                String floralOption[] ={ "Cut Flowers = $15.00","Floral Arrangemen = $25.00","Coursages = 10.00","None"};
                if (Cut Flowers)
                    System.out.print("Submit = $15.00");
                else
                    if (Floral Arrangement)
                        System.out.print("Submit = $25.00");
                    else
                        if (Coursage)
                            System.out.print("$10.00");
                        else
                            System.out.print("None");

                String dominantFlower[] = { "Roses = $5.00", "Daisies", "Chrysanthemums", "Irises"};

                if (roses)
                    System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
                else
                    System.out.print("$15.00"); ("$25.00"); ("$10.00");


                String dOption[]= { "Drop Off = $10.00", "Pick Up"};

                if (Drop Off)
                    System.out.print("$10.00");
                else
                    ystem.out.print("PickUp");
            }

        }

Recommended Answers

All 20 Replies

how to get it without the errors

I don't see where you posted the errors.

sorry about that the errors are the if and else statements.

No, I meant the error messages output by the compiler.
Where are they?

it says cannot find symbol
the symbols are th ones in the if statement bracket
illegal start
even calls the class out from sysytem.out.print as a symbol it cannot find
<identifier> expected
')' expected and it says the first else does not have an if statement

Where did those error messages come from?

Please copy and paste the full text of the error messages from the compiler.
Your edited version has left off important information.

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code
at floralorder.flowerOrder.<init>(flowerOrder.java:39)
at floralorder.flowerOrder.main(flowerOrder.java:169)
Java Result: 1

this is what it says but it only state these errors on these two line but there is more.

oh i finally get it with all the errors.
Compiling 10 source files to C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\build\classes
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:115: ')' expected
if (Cut Flowers)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:115: not a statement
if (Cut Flowers)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:115: ';' expected
if (Cut Flowers)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:117: 'else' without 'if'
else
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:118: <identifier> expected
if (floralArrangement)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:119: <identifier> expected
System.out.print("Submit = $25.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:119: illegal start of type
System.out.print("Submit = $25.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:120: illegal start of type
else
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:121: <identifier> expected
if (Coursage)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:122: <identifier> expected
System.out.print("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:122: illegal start of type
System.out.print("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:123: illegal start of type
else
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:124: <identifier> expected
System.out.print("None");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:124: illegal start of type
System.out.print("None");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:128: illegal start of type
if (roses)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:128: <identifier> expected
if (roses)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: <identifier> expected
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: illegal start of type
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: illegal start of type
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: illegal start of type
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: illegal start of type
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:129: illegal start of type
System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:130: illegal start of type
else
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: <identifier> expected
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: illegal start of type
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: illegal start of type
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: illegal start of type
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: illegal start of type
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:131: illegal start of type
System.out.print("$15.00"); ("$25.00"); ("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:136: illegal start of type
if (Drop Off)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:136: ';' expected
if (Drop Off)
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:137: <identifier> expected
System.out.print("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:137: illegal start of type
System.out.print("$10.00");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:138: illegal start of type
else
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:139: <identifier> expected
ystem.out.print("PickUp");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralOrderGUI.java:139: illegal start of type
ystem.out.print("PickUp");
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:48: not a statement
customerName;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:56: not a statement
dominantFlower;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:64: not a statement
orderCost;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:72: not a statement
orderNo;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:80: not a statement
deliveryOption;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\floralOrder.java:88: not a statement
floralOption;
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:119: <identifier> expected
name =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:122: <identifier> expected
floralOption =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:125: <identifier> expected
deliveryOption =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:128: <identifier> expected
orderNo =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:131: <identifier> expected
orderCost =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:141: <identifier> expected
outputStr = "Name: " + name + "\n" + "FloralOption: " + floralOption + "\n" +
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:144: <identifier> expected
JOptionPane.showMessageDialog(null, outputStr, "ViewOrder",
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:144: illegal start of type
JOptionPane.showMessageDialog(null, outputStr, "ViewOrder",
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:153: <identifier> expected
name =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:156: <identifier> expected
floralOption =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:159: <identifier> expected
deliveryOption =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:162: <identifier> expected
orderNo =
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\src\floralorder\flowerOrder.java:165: <identifier> expected
orderCost =
55 errors
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\nbproject\build-impl.xml:413: The following error occurred while executing this line:
C:\Users\Juanelle\Documents\NetBeansProjects\floralOrder\nbproject\build-impl.xml:199: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

Is this a compile time problem or an execution time problem?
The error message you posted looks like execution time:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code

You don't get exceptions when compiling a source

The code you posted only shows 139 lines, but the error message refers to line 169

Are you working with a different program than what was posted?

Ok now I see the compile time errors.

if (Cut Flowers)

The expression in the ()s must evaluate to a boolean value: true or false.
"Cut Flowers" is not a boolean expression.

The other errors may be due to mismatched ()s or {}s
You need to post the sourcecode that generates the errors.

the code with the errors

String floralOption[] ={ "Cut Flowers = $15.00","Floral Arrangemen = $25.00","Coursages = 10.00","None"};
                if {Cut Flowers}
                    System.out.print("Submit = $15.00");
                else
                    if (floralArrangement)
                        System.out.print("Submit = $25.00");
                    else
                        if (Coursage)
                            System.out.print("$10.00");
                        else
                            System.out.print("None");

                String dominantFlower[] = { "Roses = $5.00", "Daisies", "Chrysanthemums", "Irises"};

                if (roses)
                    System.out.print("$15.00" + "$5.00" );("$25.00" + "$5.00");("$10.00" + "$5.00");
                else
                    System.out.print("$15.00"); ("$25.00"); ("$10.00");


                String dOption[]= { "Drop Off = $10.00", "Pick Up"};

                if (Drop Off)
                    System.out.print("$10.00");
                else
                    ystem.out.print("PickUp");
            }

        }
if {Cut Flowers}

What is this statement supposed to do? Its syntax is invalid.
Are you trying to determine if a variable(a String) has the contents of "Cut Flowers"?

it suppose to mean if the individual chooses cut flowers then it will cost $15.00 and so on.

You are running ahead. There is nothing I posted about cost or $15. That comes later.

I am asking what the single statement I posted is supposed to do?
if() statements require binary expressions in the (). Cut Flowers is not a boolean expression, so the compiler gives an error message.
What condition do you want to test here? What boolean expression represents that test?

if choice is to cut flowers

if choice is to cut flowers

Ok, that's in English.
Now write it in Java:
What is a "choice"?
How do you test the "choice" to see if it is "cut flowers"?

what wrong with this?

if(choice == cut flowers)

What does the compiler say? That's the quickest way to get error messages for a line of code.

cut flowers looks like two variables: cut and flowers. What is the compile supposed to do with them? Add them together? Subtract one from the other?

If you want a String then you need to add " to both ends: "cut flowers".

To compare the contents of two objects, use a method, do NOT USE the == operator.
To find what method to use, read the API doc for the classes involved.

now choice is underlined as an error but getting problems to build with netbeams

6.8 getting the sames errors that i had before even though in the code the errors

decreased how can this be fixed to see the current error info.

Please copy full text of error message and paste it here. Here is a sample:

TestSorts.java:138: cannot find symbol
symbol : variable var
location: class TestSorts
var = 2;
^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.