Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Programming Problems Need Help

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    6
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Programming Problems Need Help

    Hello,

    I can't get this to compile and and am also having trouble with setting up the east panel text field for a user to input any string of characters to get charged "1.00", but if left blank no addtional charges "0.00" are added from this panel.
    The rest of the program tallies a sum consisting of all checked or radio buttoned options and displays the total upon clicking an "Order" button.
    I believe I was supposed to set this up as an Application using :

    public static void (String[] args)

    However the examples I could find couldn't show me how to tie the different panels into one border layout.
    The example I did find used:

    public void init()

    I spent the last few days adapting the example to my needs and believe overload and burnout are a factor. Please help with a direction and/or examples. I feel I am closer to achieving the goals with this one rather than aborted attempts or starting over. By the way my lab partner kinda ditched me on this so I'm trying to finish it all before Tuesday.

    Any help would be greatly appreciated, Thanks
    Chuck


    //************************************************** ***//
    // Pizza Project Authors: Chuck ????????????, Nick ??????????. //
    // //
    //--------------------Pizza Ordering Program----------------------------//

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import java.applet.*;


    public class PizzaOrdersProgram extends Applet implements ActionListener, KeyListener
    {
    private JLabel size;
    private JRadioButton small, medium, large;
    private JCheckBox anchovies, canadian_bacon, salami, pepperoni, sausage, mushroom, olive, onion, green_pepper;
    private String smallSize, mediumSize, largeSize;

    //---Pizza Options Pricing---//

    private final double smallSizePrice = 5.00,
    mediumSizePrice = 10.00,
    largeSizePrice = 15.00,
    thinTypePrice = 0.00,
    thickTypePrice = 0.00,
    panTypePrice = 1.50,
    anchoviesToppingPrice = 1.00,
    canadian_baconToppingPrice = 1.00,
    salamiToppingPrice = 1.00,
    pepperoniToppingPrice = 1.00,
    sausageToppingPrice = 1.00,
    mushroomToppingPrice = 1.00,
    oliveToppingPrice = 1.00,
    onionToppingPrice = 1.00,
    green_pepperToppingPrice = 1.00,
    textBoxPrice = 1.00;

    //-------GUI Setup-------//

    Panel northPanel,
    sizePanel,
    westPanel,
    westTypePanel,
    centerPanel,
    centerToppingPanel,
    eastPanel,
    eastTextPanel,
    southPricePanel,
    southPanel;

    Label titleLabel,
    sizeLabel,
    typeLabel,
    textLabel,
    amountLabel,
    toppingLabel,
    inputLabel,
    outputLabel,
    resultsLabel,
    priceLabel,
    priceDisplayLabel;

    Button orderButton;

    TextField pizzaText,
    priceText;

    ButtonGroup sizeBGroup;

    JRadioButton smallJRadioButton,
    mediumJRadioButton,
    largeJRadioButton,
    thinJRadioButton,
    thickJRadioButton,
    panJRadioButton;

    JCheckBox anchoviesJCheckBox,
    canadian_baconJCheckBox,
    salamiJCheckBox,
    pepperoniJCheckBox,
    sausageJCheckBox,
    mushroomJCheckBox,
    oliveJCheckBox,
    onionJCheckBox,
    green_pepperJCheckBox;

    //--------------------------------------------------------------//
    // Setup Panels with Radio Buttons, Checkboxes, & Text Field //
    //--------------------------------------------------------------//

    public void init()
    {
    setBackground(new Color(green));
    setLayout(new BorderLayout(0,0));

    northPanel = new Panel();
    northPanel.setBackground(new Color(green));
    northPanel.setLayout(new FlowLayout());
    northSizePanel = new Panel();
    northSizePanel.setLayout(new FlowLayout());

    westTypePanel = new Panel();
    westTypePanel.setBackground(new Color(green));
    westTypePanel.setLayout(new FlowLayout());

    centerPanel = new Panel();
    centerToppingPanel = new Panel();
    centerToppingPanel.setBackground(new Color(green));
    centerToppingPanel.setLayout(new FlowLayout());

    eastPanel = new Panel();
    eastTextBoxPanel = new Panel();
    eastTextBoxPanel.setBackground(new Color(green));
    eastTextBoxPanel.setLayout (new Flowlayout());

    southPanel = new Panel();
    southPanel.setLayout(new FlowLayout());
    southPricePanel = new Panel();
    southPricePanel.setBackground(new Color(green));
    southPricePanel.setLayout(new FlowLayout());


    //---Radio Buttons---//

    smallJRadioButton = new JRadioButton("Small", false);
    regularJRadioButton = new JRadioButton("Regular", true);
    largeJRadioButton = new JRadioButton("Large", false);

    thinJRadioButton = new JRadioButton("Thin", false);
    thickJRadioButton = new JRadioButton("Thick", true);
    panJRadioButton = new JRadioButton("Pan", false);

    sizeBGroup = new ButtonGroup();
    sizeBGroup.add(smallJRadioButton);
    sizeBGroup.add(regularJRadioButton);
    sizeBGroup.add(largeJRadioButton);

    typeCGroup = new ButtonGroup();
    typeCGroup.add(thinJRadioButton);
    typeCGroup.add(thickJRadioButton);
    typeCGroup.add(panJRadioButton);

    //---CheckBoxes---//

    anchoviesJCheckBox = new JCheckBox("Anchovies",false);
    canadian_baconJCheckBox = new JCheckBox("Canadian Bacon",false);
    salamiJCheckBox = new JCheckBox("Salami",false);
    pepperoniJCheckBox = new JCheckBox("Pepperoni",false);
    sausageJCheckBox = new JCheckBox("Sausage",false);
    mushroomJCheckBox = new JCheckBox("Mushroom",false);
    oliveJCheckBox = new JCheckBox("Olive",false);
    onionJCheckBox = new JCheckBox("Onion",false);
    green-pepperJCheckBox = new JCheckBox("Green Pepper",false);

    //---TextBox---//

    pizzaText = new TextField("0",1);
    pizzaText.setFont(new Font("Tahoma",Font.BOLD,12));

    //---Ordering Button---//

    orderButton = new Button("Order Now");
    orderButton.setFont(new Font("Tahoma",Font.BOLD,14));

    //---Setup Listeners---//

    smallJRadioButton.addActionListener(this);
    regularJRadioButton.addActionListener(this);
    largeJRadioButton.addActionListener(this);
    thinJRadioButton.addActionListener(this);
    thickJRadioButton.addActionListener(this);
    panJRadioButton.addActionListener(this);
    anchoviesJCheckBox.addActionListener(this);
    canadian_baconJCheckBox.addActionListener(this);
    salamiJCheckBox.addActionListener(this);
    pepperoniJCheckBox.addActionListener(this);
    sausageJCheckBox.addActionListener(this);
    mushroomJCheckBox.addActionListener(this);
    oliveJCheckBox.addActionListener(this);
    onionJCheckBox.addActionListener(this);
    green_pepperJCheckBox.addActionListener(this);
    pizzaTextBox.addKeyListener(this);
    orderButton.addActionListener(this);


    //---Setup Labels---//

    titleLabel = new Label("");
    titleLabel.setBackground(new Color(green));
    titleLabel.setForeground(new Color(red));
    titleLabel.setFont(new Font("Tahoma",Font.BOLD,40));
    sizeLabel = new Label("Select a size for your custom-made pizza:");
    sizeLabel.setForeground(new Color(red));
    typeLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    typeLabel = new Label("Select a crust type for your custom-made pizza:");
    typeLabel.setForeground(new Color(red));
    typeLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    toppingLabel = new Label("Select one or more choices of the toppings below : ");
    toppingLabel.setForeground(new Color(red));
    toppingLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    textBoxLabel =new Label("Type in non-listed pizza topping:");
    textBoxLabel.setForeground(new Color(red));
    textBoxLabel.SetFont (new Font("Tahoma",Font.BOLD,12));
    amountLabel = new Label("Amount: ");
    amountLabel.setForeground(new Color(0,0,0));
    amountLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    priceLabel = new Label("Total price of your order : ");
    priceLabel.setForeground(new Color(red));
    priceLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    priceDisplayLabel = new Label("$0.00 ");
    priceDisplayLabel.setForeground(new Color(red));
    priceDisplayLabel.setFont(new Font("Tahoma",Font.BOLD,30));
    }


    //---Nesting the Panels---//

    public void start()
    {
    northPanel.add(sizeLabel);
    northSizePanel.add(smallJRadioButton);
    northSizePanel.add(regularJRadioButton);
    northSizePanel.add(largeJRadioButton);

    westTypePanel.add(typeLabel);
    westTypePanel.add(thinJRadioButton);
    westTypePanel.add(thickJRadioButton);
    westTypePanel.add(panJRadioButton);

    centerPanel.add(toppingLabel);
    centerToppingPanel.add(anchoviesJCheckBox);
    centerToppingPanel.add(canadian_baconJCheckBox);
    centerToppingPanel.add(salamiJCheckBox);
    centerToppingPanel.add(sausageJCheckBox);
    centerToppingPanel.add(mushroomJCheckBox);
    centerToppingPanel.add(oliveJCheckBox);
    centerToppingPanel.add(onionJCheckBox);
    centerToppingPanel.add(green_pepperJCheckBox);


    eastTextBoxPanel.add(inputLabel);
    eastTextBoxPanel.add(outputLabel);
    eastTextBoxPanel.add(resultsLabel);

    southPanel.add(southPricePanel);
    southPricePanel.add(amountLabel);
    southPricePanel.add(priceLabel);
    southPricePanel.add(priceDisplayLabel);
    southPricePanel.add(orderButton);

    //---Setup Border---//

    add(northPanel, BorderLayout.NORTH);
    add(westpanel, BorderLayout.WEST);
    add(centerPanel, BorderLayout.CENTER);
    add(eastPanel, BorderLayout.EAST);
    add(southPanel, BorderLayout.SOUTH);
    pizzaText.selectAll();
    }


    public void keyTyped(KeyEvent e) { }
    public void keyPressed(KeyEvent e) { }
    public void keyReleased(KeyEvent e)
    {

    //---If no text entered---//
    try
    {
    String.parseString(pizzaText.getText());
    }
    catch (StringFormatException fe) {
    pizzaText.setText("0");
    }
    refreshPrice();
    }

    //---Order Button Action---//

    public void actionPerformed(ActionEvent e)
    {
    if (e.getSource() == orderButton)
    {
    JOptionPane.showMessageDialog(this,
    "Thank you for your " +
    priceDisplayLabel.getText() + " payment." +
    "\n\nYour custom pizza will be delivered to you shortly via owl!" +
    "\nThank You for your Business! Happy Holidays!",
    "Orders Confirmed",
    JOptionPane.INFORMATION_MESSAGE);
    }
    refreshPrice();
    }

    //---format input string to value---//

    private void refreshPrice()
    {
    double price = 0;
    double pizzaAmount = String.parseString(pizzaText.getText());
    DecimalFormat moneyForm = (DecimalFormat)numberForm;
    moneyForm.applyPattern("1.00");


    //*******If Statements*******//

    //---Radio Buttons Priced---//

    if (smallJRadioButton.isSelected()) {
    price+= smallPizzaPrice * pizzaAmount;
    }
    if (regularJRadioButton.isSelected()) {
    price+= regularPizzaPrice * pizzaAmount;
    }
    if (largeJRadioButton.isSelected()) {
    price+= largePizzaPrice * pizzaAmount;
    }
    if (thinJRadioButton.isSelected()) {
    price+= thinPizzaPrice * pizzaAmount;
    }
    if (thickJRadioButton.isSelected()) {
    price+= thickPizzaPrice * pizzaAmount;
    }
    if (panJRadioButton.isSelected()) {
    price+= panPizzaPrice * pizzaAmount;
    }

    //---CheckBoxes priced---//

    if (anchoviesJCheckBox.isSelected())
    {
    price+= anchoviesToppingPrice * pizzaAmount;
    if (canadian_baconJCheckBox.isSelected())
    {
    price+= canadian_baconToppingPrice * pizzaAmount;
    if (salamiJCheck.isSelected())
    {
    price+= salamiToppingPrice * pizzaAmount;
    if (pepperoniJCheckBox.isSelected())
    {
    price+= pepperoniToppingPrice * pizzaAmount;
    if (sausageJCheckBox.isSelected())
    {
    price+= sausageToppingPrice * pizzaAmount;
    }
    if (mushroomJCheckbox.isSelected())
    {
    price+= mushroomToppingPrice * pizzaAmount;
    }
    if (oliveJCheckBox.isSelected())
    {
    price+= oliveToppingPrice * pizzaAmount;
    }
    if (onionJCheckBox.isSelected()) {
    price+= onionToppingPrice * pizzaAmount;
    }
    if (green_pepperJCheckBox.isSelected()) {
    price+= green_pepperToppingPrice * pizzaAmount;
    }
    priceDisplayLabel.setText("$"+moneyForm.format(pri ce));
    }
    }


  2. #2
    Junior Member
    Join Date
    Dec 2011
    Posts
    6
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Programming Problems Need Help

    I am actually working on a second version that is an Application using:

    public static void main (String[] args)

    I will probably do it both ways as I'm continuing to learn as I go and any practice will help the lessons & lecture sink in better. I've already had a few "Aha" moments. Athough I believe this would be more usable if it could run in a browser rather than as free-standing application. Thanks again. Chuck

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Problems Need Help

    Please Edit your post and wrap your code with
    [code=java]<YOUR CODE HERE>[/code] to get highlighting and preserve formatting. Your unformatted code is hard to read.

    I can't get this to compile
    Please copy and paste here the full text of the error messages.

  4. The Following User Says Thank You to Norm For This Useful Post:

    ChuckLep (December 12th, 2011)

  5. #4
    Junior Member
    Join Date
    Dec 2011
    Posts
    6
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Programming Problems Need Help

    Sure np, I have 1 error on the last " } " which is :
    PizzaOrderingProgramPanel.java:367: error: reached end of file while parsing
    I appreciate any insight or advice to clear this up. Thanks, Chuck

    <
    //*******************************************************//
    // Pizza Project	Authors: Chuck Armstrong, Nick Gesick. //
    //                                                       //
    //--------------Pizza Ordering Program-------------------//
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import java.util.*;
     
     
     
    public class PizzaOrderingProgramPanel extends JFrame implements ActionListener, KeyListener
    {
    	private JLabel size;
    	private JLabel type;
    	private JRadioButton small, medium, large;
    	private JRadioButton thin, thick, pan;
    	private JCheckBox anchovies, canadian_bacon, salami, pepperoni, sausage, mushroom, olive, onion, green_pepper;
    	private String smallSize, mediumSize, largeSize;
    	private String thinType, thickType, panType;
     
    	//---Pizza Options Pricing---//
     
    	private final double	smallSizePrice = 5.00,
    	mediumSizePrice = 10.00,
    	largeSizePrice = 15.00,
    	thinTypePrice = 0.00,
    	thickTypePrice = 0.00,
    	panTypePrice = 1.50,
    	anchoviesToppingPrice = 1.00,
    	canadian_baconToppingPrice = 1.00,
    	salamiToppingPrice = 1.00,
    	pepperoniToppingPrice = 1.00,	
    	sausageToppingPrice = 1.00,
    	mushroomToppingPrice = 1.00,
    	oliveToppingPrice = 1.00,
    	onionToppingPrice = 1.00,
    	green_pepperToppingPrice = 1.00,
    	textBoxPrice = 1.00;
     
    	//-------GUI Setup-------//
     
    	Panel northPanel,
    			sizePanel,
    			westPanel,
    			westTypePanel,
    			centerPanel,	
    			centerToppingPanel,
    			eastPanel,
    			eastTextPanel,
    			southPricePanel,
    			southPanel;
     
    	Label titleLabel,
    			sizeLabel,
    			typeLabel,
    			textLabel,
    			amountLabel,
    			toppingLabel,
    			inputLabel,
    			outputLabel,
    			resultsLabel,
    			priceLabel,
    			priceDisplayLabel;
     
    	Button orderButton;
     
    	TextField pizzaText,
    				 priceText;
     
    	ButtonGroup sizeBGroup;	
     
    	JRadioButton smallJRadioButton,
    					 mediumJRadioButton,
    					 largeJRadioButton;
    	ButtonGroup typeCGroup;
     
    	JRadioButton thinJRadioButton,
    					 thickJRadioButton,
    					 panJRadioButton;
     
    	JCheckBox anchoviesJCheckBox,
    				 canadian_baconJCheckBox,		
    				 salamiJCheckBox,
    				 pepperoniJCheckBox,
    				 sausageJCheckBox,
    				 mushroomJCheckBox,
    				 oliveJCheckBox,
    				 onionJCheckBox,
    				 green_pepperJCheckBox;
     
    	//--------------------------------------------------------------//
    	//  Setup Panels with Radio Buttons, Checkboxes, & Text Field   //
    	//--------------------------------------------------------------//
     
    	public PizzaOrderingProgramPanel()
    	{
    		setBackground(new Color(green));
    		setLayout(new BorderLayout(0,0));
     
    		northPanel = new Panel();
    		northPanel.setBackground(new Color(green));
    		northPanel.setLayout(new FlowLayout());
    		northSizePanel = new Panel();
    		northSizePanel.setLayout(new FlowLayout());
     
    		westTypePanel = new Panel();
    		westTypePanel.setBackground(new Color(green));
    		westTypePanel.setLayout(new FlowLayout());
     
    		centerPanel = new Panel();
    		centerToppingPanel = new Panel();
    		centerToppingPanel.setBackground(new Color(green));
    		centerToppingPanel.setLayout(new FlowLayout());
     
    		eastPanel = new Panel();
    		eastTextBoxPanel = new Panel();
    		eastTextBoxPanel.setBackground(new Color(green));
    		eastTextBoxPanel.setLayout (new Flowlayout());
     
    		southPanel = new Panel();
    		southPanel.setLayout(new FlowLayout());
    		southPricePanel = new Panel();
    		southPricePanel.setBackground(new Color(green));
    		southPricePanel.setLayout(new FlowLayout());
     
     
    		//---Radio Buttons---//
     
    		smallJRadioButton = new JRadioButton("Small", false);
    		regularJRadioButton = new JRadioButton("Regular", true);
    		largeJRadioButton = new JRadioButton("Large", false);
     
    		thinJRadioButton = new JRadioButton("Thin", false);
    		thickJRadioButton = new JRadioButton("Thick", true);
    		panJRadioButton = new JRadioButton("Pan", false);
     
    		sizeBGroup = new ButtonGroup();
    		sizeBGroup.add(smallJRadioButton);
    		sizeBGroup.add(regularJRadioButton);
    		sizeBGroup.add(largeJRadioButton);
     
    		typeCGroup = new ButtonGroup();
    		typeCGroup.add(thinJRadioButton);
    		typeCGroup.add(thickJRadioButton);
    		typeCGroup.add(panJRadioButton);
     
    		//---CheckBoxes---//
     
    		anchoviesJCheckBox = new JCheckBox("Anchovies",false);
    		canadian_baconJCheckBox = new JCheckBox("Canadian Bacon",false);
    		salamiJCheckBox = new JCheckBox("Salami",false);
    		pepperoniJCheckBox = new JCheckBox("Pepperoni",false);
    		sausageJCheckBox = new JCheckBox("Sausage",false);
    		mushroomJCheckBox = new JCheckBox("Mushroom",false);
    		oliveJCheckBox = new JCheckBox("Olive",false);
    		onionJCheckBox = new JCheckBox("Onion",false);
    		green-pepperJCheckBox = new JCheckBox("Green Pepper",false);
     
    	              //---TextBox---//
     
    		pizzaText = new TextField("0",1);
    		pizzaText.setFont(new Font("Tahoma",Font.BOLD,12));
     
    		//---Ordering Button---//
     
    		orderButton = new Button("Order Now");
    		orderButton.setFont(new Font("Tahoma",Font.BOLD,14));
     
    		//---Setup Listeners---//
     
    		smallJRadioButton.addActionListener(this);
    		regularJRadioButton.addActionListener(this);
    		largeJRadioButton.addActionListener(this);
    		thinJRadioButton.addActionListener(this);
    		thickJRadioButton.addActionListener(this);
    		panJRadioButton.addActionListener(this);
    		anchoviesJCheckBox.addActionListener(this);
    		canadian_baconJCheckBox.addActionListener(this);
    		salamiJCheckBox.addActionListener(this);
    		pepperoniJCheckBox.addActionListener(this);
    		sausageJCheckBox.addActionListener(this);
    		mushroomJCheckBox.addActionListener(this);
    		oliveJCheckBox.addActionListener(this);
    		onionJCheckBox.addActionListener(this);
    		green_pepperJCheckBox.addActionListener(this);
    		pizzaTextBox.addKeyListener(this);
    		orderButton.addActionListener(this);
     
     
    		//---Setup Labels---//
     
    		titleLabel = new Label("");
    		titleLabel.setBackground(new Color(green));
    		titleLabel.setForeground(new Color(red));
    		titleLabel.setFont(new Font("Tahoma",Font.BOLD,40));
    		sizeLabel = new Label("Select a size for your custom-made pizza:");
    		sizeLabel.setForeground(new Color(red));
    		typeLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    		typeLabel = new Label("Select a crust type for your custom-made pizza:");
    		typeLabel.setForeground(new Color(red));
    		typeLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    		toppingLabel = new Label("Select one or more choices of the toppings below : ");
    		toppingLabel.setForeground(new Color(red));
    		toppingLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    		textBoxLabel =new Label("Type in non-listed pizza topping:");
    		textBoxLabel.setForeground(new Color(red));
    		textBoxLabel.SetFont (new Font("Tahoma",Font.BOLD,12));
    		amountLabel = new Label("Amount: ");
    		amountLabel.setForeground(new Color(0,0,0));
    		amountLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    		priceLabel = new Label("Total price of your order : ");
    		priceLabel.setForeground(new Color(red));
    		priceLabel.setFont(new Font("Tahoma",Font.BOLD,12));
    		priceDisplayLabel = new Label("$0.00 ");
    		priceDisplayLabel.setForeground(new Color(red));
    		priceDisplayLabel.setFont(new Font("Tahoma",Font.BOLD,30));
    		}
     
     
    		//---Nesting the Panels---//
     
    		public static void main (String[] args)
    		{	
    			northPanel.add(sizeLabel);						
    			northSizePanel.add(smallJRadioButton);
    			northSizePanel.add(regularJRadioButton);
    			northSizePanel.add(largeJRadioButton);
     
    			westTypePanel.add(typeLabel);
    			westTypePanel.add(thinJRadioButton);
    			westTypePanel.add(thickJRadioButton);
    			westTypePanel.add(panJRadioButton);
     
    			centerPanel.add(toppingLabel);
    			centerToppingPanel.add(anchoviesJCheckBox);
    			centerToppingPanel.add(canadian_baconJCheckBox);
    			centerToppingPanel.add(salamiJCheckBox);
    			centerToppingPanel.add(sausageJCheckBox);
    			centerToppingPanel.add(mushroomJCheckBox);
    			centerToppingPanel.add(oliveJCheckBox);
    			centerToppingPanel.add(onionJCheckBox);
    			centerToppingPanel.add(green_pepperJCheckBox);
     
     
    			eastTextBoxPanel.add(inputLabel);
    			eastTextBoxPanel.add(outputLabel);
    			eastTextBoxPanel.add(resultsLabel);
     
    			southPanel.add(southPricePanel);
    			southPricePanel.add(amountLabel);
    			southPricePanel.add(priceLabel);
    			southPricePanel.add(priceDisplayLabel);
    			southPricePanel.add(orderButton);
     
    			//---Setup Border---//
     
    			add(northPanel, BorderLayout.NORTH);
    			add(westpanel, BorderLayout.WEST);
    			add(centerPanel, BorderLayout.CENTER);
    			add(eastPanel, BorderLayout.EAST);
    			add(southPanel, BorderLayout.SOUTH);
    			pizzaText.selectAll();
    			}
     
     
    			public void keyTyped(KeyEvent e) { }
    			public void keyPressed(KeyEvent e) { }		
    			public void keyReleased(KeyEvent e)
    		             {
     
    			//---If no text entered---// 
    			try
    			{
    			String.parseString(pizzaText.getText());
    			}
    			catch (StringFormatException fe) {
    			pizzaText.setText("0");
    			}
    			refreshPrice();
    			} 
     
    			//---Order Button Action---//			
     
    			public void actionPerformed(ActionEvent e)
    			{
    			if (e.getSource() == orderButton)
    			{
    			JOptionPane.showMessageDialog(this,
    			"Thank's for your " + 
    			priceDisplayLabel.getText() + " payment." +
    			"\n\nYour custom pizza will be delivered to you shortly via owl!" + 
    			"\nThank You for your Business! Happy Holidays!",
    			JOptionPane.INFORMATION_MESSAGE);
    			}
    			refreshPrice();
    			}
    			//---Text String Converted to Value---//
     
    			private void refreshPrice()
    			{			
    			double price = 0;
    			double pizzaAmount = String.parseString(pizzaText.getText());
    			DecimalFormat moneyForm = (DecimalFormat)numberForm;
    			moneyForm.applyPattern("1.00");
     
     
    			//*******If Statements*******//
     
    			//---Radio Buttons Priced---//
     
    			if (smallJRadioButton.isSelected()) {
    			price+= smallPizzaPrice * pizzaAmount;
    			}
    			if (regularJRadioButton.isSelected()) {
    			price+= regularPizzaPrice * pizzaAmount;
    			}
    			if (largeJRadioButton.isSelected()) {
    			price+= largePizzaPrice * pizzaAmount;
    			}
    			if (thinJRadioButton.isSelected()) {
    			price+= thinPizzaPrice * pizzaAmount;
    			}
    			if (thickJRadioButton.isSelected()) {
    			price+= thickPizzaPrice * pizzaAmount;
    			}
    			if (panJRadioButton.isSelected()) {
    			price+= panPizzaPrice * pizzaAmount;
    			}
     
    			//---CheckBoxes priced---//
     
    			if (anchoviesJCheckBox.isSelected())
    		              {
    			price+= anchoviesToppingPrice * pizzaAmount;
    			if (canadian_baconJCheckBox.isSelected())
    			{
    			price+= canadian_baconToppingPrice * pizzaAmount;
    			if (salamiJCheck.isSelected())
    			{
    			price+= salamiToppingPrice * pizzaAmount;
    			if (pepperoniJCheckBox.isSelected())
    			{
    			price+= pepperoniToppingPrice * pizzaAmount;
    			if (sausageJCheckBox.isSelected())
    			{
    			price+= sausageToppingPrice * pizzaAmount;
    			}
    			if (mushroomJCheckbox.isSelected())
    			{
    			price+= mushroomToppingPrice * pizzaAmount;
    			}
    			if (oliveJCheckBox.isSelected())
    			{
    			price+= oliveToppingPrice * pizzaAmount;
    			}
    			if (onionJCheckBox.isSelected()) {
    			price+= onionToppingPrice * pizzaAmount;
    			}
    			if (green_pepperJCheckBox.isSelected()) {
    			price+= green_pepperToppingPrice * pizzaAmount;
    			}
    			priceDisplayLabel.setText("$"+moneyForm.format(price));
    			}
    	                        }>

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Problems Need Help

    Looks like you have a missing }
    Some IDEs/editors have a Find the pairing {}s tool. Put the cursor on one and it finds the other.
    My editor uses: CTL + ]

    Otherwise look at the code for missing }s.

    Try adding one or more }s at the end and see it you get different error messages that may narrow down the search.

  7. The Following User Says Thank You to Norm For This Useful Post:

    ChuckLep (December 12th, 2011)

  8. #6
    Junior Member
    Join Date
    Dec 2011
    Posts
    6
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Programming Problems Need Help

    Thank you I did that and found one missing "}" in a {} pair and it turned up other errors. I am working on the new errors. I'll repost a new thread once I get stuck again.
    Again Thanks a Heap!

    New Thread started:
    Remaining compile errors: no suitable method found for & cannot find symbol
    Last edited by ChuckLep; December 12th, 2011 at 01:42 PM. Reason: This problem resolved new thread started

Similar Threads

  1. [SOLVED] NIO Problems
    By bgroenks96 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: November 12th, 2011, 06:26 PM
  2. MP3 problems
    By relion65 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 15th, 2011, 12:09 PM
  3. 2 problems...
    By Day2Day in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 22nd, 2010, 02:51 PM
  4. [SOLVED] Have a few odd problems.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: October 19th, 2010, 06:08 PM
  5. rmi problems
    By deepthought in forum Java SE APIs
    Replies: 7
    Last Post: September 7th, 2010, 07:25 PM