Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help Needed Please!!

807599Apr 13 2007 — edited Apr 13 2007
I have created a frame that has 5 instances of it. the code compiles and runs fine until i try to set a name for each frame and location.
I would greatly appreciate any guidance as to how i can set a title and setLocation of the 5 frames.
My code is as follows.
Thankyou.
/**
 * @(#)MySuperMarket.java
 *
 * MySuperMarket application
 *
 * @author 
 * @version 1.00 2007/4/13
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Observer;  //new
import java.util.Observable;//new
 
public class MySuperMarket
{
	public MySuperMarket()
	{
	
		CheckoutView Check1 = new CheckoutView(1);
		CheckoutView Check2 = new CheckoutView(2);
		CheckoutView Check3 = new CheckoutView(3);
		CheckoutView Check4 = new CheckoutView(4);
		CheckoutView Check5 = new CheckoutView(5);
		
	}
    
    public static void main(String[] args) {
    	
    	// TODO, add your application code
    	System.out.println("Starting My Supermarket Project...");
    	MySuperMarket startup = new MySuperMarket();
    }
}
    class CheckoutView
{
	private OfficeView offObj1;
	private JFrame chk1;
	private Container cont1;
	private Dimension screensize;
	private JPanel panN,panS,panC;
	private JButton buyBut,prodCode;
	private JButton purchase,cashBack,manual,remove;

	private ButtonGroup bGRP;
	private JRadioButton rb1,rb2,rb3,rb4;
	private JTextArea ta1;
	private JTextField tf1,tf2;
	private JTextField tf5,tf6;
	private JLabel lab1,lab2;

	public CheckoutView(int.passedInteger) //this is where the error is showing
	{
		//offObj1 = new OfficeView();
		drawCheckoutGui();
	}
	public void drawCheckoutGui()
	{
		screensize = Toolkit.getDefaultToolkit().getScreenSize();
		chk1 = new JFrame();
		this.setTitle("Checkout" + passedInteger);
		int frameWidth = 300;
		int frameHeight = 350;
		chk1.setSize(frameWidth,frameHeight);
		chk1.setLocation(0,0);
		chk1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		cont1 = chk1.getContentPane();
		//panel c
		panC = new JPanel();
		panC.setLayout(new FlowLayout());
		panC.setBackground(Color.black);
		tf1 = new JTextField(20);
		lab1 = new JLabel("Total amount due is ?");
		lab1.setForeground(Color.white);
		buyBut = new JButton("Finalize");
		manual = new JButton("Manual");
		remove = new JButton("Remove");
		ta1 = new JTextArea(8,20);
		ta1.setText("                   Customer Receipt");
		ta1.setEditable(false);
		cashBack = new JButton("Cashback");
		panC.add(manual);
		panC.add(remove);
		panC.add(ta1);
		panC.add(buyBut);
		panC.add(cashBack);
		panC.add(lab1);
		panC.add(tf1);		
		panN = new JPanel();
		panN.setLayout(new BorderLayout());
		panN.setBackground(Color.black);
		lab2 = new JLabel("Product Barcode ");
		lab2.setForeground(Color.white);
		purchase = new JButton("Purchase");
		tf2 = new JTextField(5);
		tf1.setEditable(false);
		panN.add(tf2,"Center");
		panN.add(purchase,"East");
		panN.add(lab2,"West");
		panS = new JPanel();
		panS.setLayout(new FlowLayout());
		bGRP = new ButtonGroup();
		rb1 = new JRadioButton("Cash");
		rb2 = new JRadioButton("Card");
		rb3 = new JRadioButton("Cheque");
		rb4 = new JRadioButton("Voucher");
		panS.add(rb1);
		panS.add(rb2);
		panS.add(rb3);
		panS.add(rb4);
		cont1.add(panS,"South");
		cont1.add(panC,"Center");
		cont1.add(panN,"North");
		chk1.setContentPane(cont1);
		chk1.setVisible(true);			
	}	
}
i have tried adding a number to the the instances of the frames and then passedInt into the constructor but i am getting an error <identifier>expected, and i have added a comment to the code where the error corresponds to.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2007
Added on Apr 13 2007
4 comments
133 views