need help with the GUI of my program...
i want it to be like this:
[IMG]http://img256.imageshack.us/img256/8919/faceeq9.th.jpg[/IMG]
but this is what it shows.. hehe
[IMG]http://img440.imageshack.us/img440/8486/caym9.th.jpg[/IMG]
im having a hard time with the GridLayout coz i think ie. GridLayout 3,4 doesnt appear to be 3,4..
thankss...
import java.awt.*;
import java.awt.event.*;
public class Project extends Frame implements ActionListener {
private TextArea display;
private TextArea msg;
public static void main (String args[]){
Project cl = new Project();
FlowLayout fl = new FlowLayout();
Panel panel1 = new Panel();
Panel panel2 = new Panel();
Panel panel3 = new Panel();
Panel panel4 = new Panel();
Panel panel5 = new Panel();
GridLayout gl = new GridLayout(1,3);
Button quit = new Button("Quit");
Button print = new Button("Print Total");
TextArea display = new TextArea("Information");
TextField msg = new TextField("%");
cl.setSize(650,500); // window size
cl.setLayout(new BorderLayout());
// PANEL 1
panel1.add(new Label ("Cash Register for Carinderias :)"));
// PANEL 2
panel2.setLayout(new GridLayout(10,0));
panel2.setSize(450,600);
panel2.add(new Label("Rice"));
panel2.add(new Label("Softdrinks"));
panel2.add(new Label("Meat"));
panel2.add(new Label("Soup"));
panel2.add(new Label("Arroz Caldo"));
panel2.add(new Label("Batchoy"));
//List list = new List (5, false); //list of items
//list.add ("Rice");
//list.add ("Softdrinks (8oz)");
//list.add ("Meat");
// list.add ("Soup");
// list.add ("Arroz Caldo");
// panel2.add(list);
//panel2.setLayout(new GridLayout(10,0));
msg.setBackground(Color.GREEN);
panel2.add(new Label("How many percent discount?"));
panel2.add(msg);
panel2.add(new Button ("Give Discount"));
// PANEL 3
Choice choose = new Choice();
choose.add("Dine In");
choose.add("Take Out");
panel3.add(choose);
//panel3.add(new Checkbox("Dine in"));
//panel3.add(new Checkbox("Take out"));
panel3.add(print);
// PANEL 4
//panel4.add(new TextArea("Information"));
display.setBackground(Color.YELLOW);
panel4.add(display);
// PANEL 5
panel5.add(new Button ("Next"), BorderLayout.CENTER);
panel5.add(quit);
quit.addActionListener(this);
// the GridLayout consist of Panels
cl.setLayout(new GridLayout(5,5));
cl.add(panel1, BorderLayout.NORTH);
cl.add(panel2, BorderLayout.CENTER);
cl.add(panel3, BorderLayout.CENTER);
cl.add(panel4, BorderLayout.CENTER);
cl.add(panel5, BorderLayout.SOUTH);
cl.setTitle("Cash Register");
cl.setVisible(true);
}
// Prints the total in the display window
public void actionPerformed(ActionEvent e)
{
if ("Print Total".equals(e.getActionCommand()))
{
String myText="";
myText=msg.getText();
display.append(myText);
if ("Quit".equals(e.getActionCommand()))
{
System.exit(0);
}
}
}
}