help me with my code

hi., please help me analyze whats wrong with my code..:(

Page 1 of 1

2 Replies - 910 Views - Last Post: 05 October 2008 - 05:13 AM Rate Topic: -----

#1 smile_myglitz08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 31-July 08

help me with my code

Post icon  Posted 05 October 2008 - 04:57 AM

good eve! is there anyone who can help me see whats wrong with my code?
am doing my homework right now..
my program completes but an exception error occurs in running it..help me please..
package PizzaOrderForm;

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

public class PizzaOrderForm extends JFrame implements ActionListener{
	   
	   JPanel mainPanel;
	   JPanel top1Panel,top2Panel,topPanel;
	   JCheckBox[] crust, topping;
	   JRadioButton[] pizzaSize,pizzaDiscount;
	   JLabel quantity,box,top,size;
	   JComboBox num1;
	   
	   String[] num={"1","2","3","4","5","6","7","8","9","10","11","12"};
	   String[] pizsize = {"Small","Medium","Large","Family size"};
	   
	   public void createPizzaForm(){
	   
	   setTitle("PIZZA ORDER FORM");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setResizable(false);	
		setLocationRelativeTo(null);
		
		
		mainPanel = new JPanel(new BorderLayout());
		top1Panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		top2Panel = new JPanel(new GridLayout(pizsize.length,1));
		
		quantity = new JLabel("QUANTITY: ");
		num1 = new JComboBox(num);
		num1.setSelectedIndex(0);
		box= new JLabel("Box(es)");
		
		top1Panel.add(quantity);
		top1Panel.add(num1);
		top1Panel.add(box);
		
		size =new JLabel("SIZES: ");
		top2Panel.add(size);
	
		ButtonGroup groupSize = new ButtonGroup();
		pizzaSize = new JRadioButton[pizsize.length];
		for(int x=0;x<pizzaSize.length;x++){
			pizzaSize[x]= new JRadioButton(pizsize[x]);
			groupSize.add(pizzaSize[x]);
			top2Panel.add(pizzaSize[x]);
		}
		
		topPanel.add(top1Panel,BorderLayout.NORTH);
		topPanel.add(top2Panel,BorderLayout.CENTER);
		mainPanel.add(topPanel,BorderLayout.NORTH);
		
	 	add(mainPanel);
		pack();
		setVisible(true);
		   
	   
	
	}
	
	public void actionPerformed(ActionEvent e) {
		Object cb = (JComboBox)e.getSource();
			   
	}
	
	 public static void main(String args[]){
		PizzaOrderForm pizza = new PizzaOrderForm();
		pizza.createPizzaForm();
		
	}
	
	
}


Is This A Good Question/Topic? 0
  • +

Replies To: help me with my code

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: help me with my code

Posted 05 October 2008 - 05:05 AM

You use the reference 'topPanel' without having created an instance. You had the same sort of error before...
Was This Post Helpful? 0
  • +
  • -

#3 smile_myglitz08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 31-July 08

Re: help me with my code

Posted 05 October 2008 - 05:13 AM

View Postg00se, on 5 Oct, 2008 - 05:05 AM, said:

You use the reference 'topPanel' without having created an instance. You had the same sort of error before...



yah! am really sorry..aheheh...but am so thakful that you help me..thanks a lot..:)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1