Help with my gui


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Help with my gui

  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Help with my gui

    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.*;
    public class TheBEST extends Frame implements ItemListener
    {
    TextField AmmountLabel;
    Label lb1,lb2,lb3,lb4,lb5;
    Label tb6,tb7;
    Label td8,td9,td10,td11,td12;
    Label ct1;
    Label ct2;
    Label ct3;
    Panel p1,p2,p3,p4,p5,p6,p7,p8,p9;
    private Checkbox StirJcheck,AbcJcheck,OysterJcheck,OldJcheck,ThaiJcheck;

    private double PackagePric = 58.00;

    private final double StirFriedCheck=2.00;
    private final double AbcMango=3.00;
    private final double OystersMombasa=5.50;
    private final double Oldfashioned=2.50;
    private final double Thaihot=4.50;


    public static void main(String[]args){

    TheBEST f= new TheBEST();
    f.setSize(400,200);
    f.setTitle("Restaurant");
    f.setVisible(true);

    }


    public TheBEST()
    {

    Font fV = new Font("Verdana", Font.BOLD,25);
    Font fA = new Font("Ariel",Font.BOLD+Font.ITALIC,13);

    setBackground(Color.pink);

    lb1= new Label("SHAZALEE BISTRO");
    lb1.setFont(fV);
    lb1.setForeground(new Color(255,0,230));


    lb2=new Label("Special Package For Today !!");
    lb2.setFont(fA);

    lb3=new Label("Tomyam : (Chicken+Meat+Crab+Fish)");
    lb3.setBackground(Color.orange);
    lb3.setForeground(Color.red);
    lb3.setFont(fA);

    lb4=new Label("Salad Relish with Thousand Island");
    lb4.setBackground(Color.orange);
    lb4.setForeground(Color.red);
    lb4.setFont(fA);

    lb5=new Label("Thai Spicy Tamarind Prawn");
    lb5.setBackground(Color.orange);
    lb5.setForeground(Color.red);
    lb5.setFont(fA);

    tb6 =new Label(" << Additional Order: >>");
    tb6.setFont(fA);

    tb7 =new Label("Number of person : ");
    tb7.setFont(fA);

    ct1 =new Label("$0.00 ");
    ct2 =new Label("$0.00 ");
    ct3=new Label("58.00");
    AmmountLabel = new TextField(4);



    p1 = new Panel();
    p1.setLayout(new BorderLayout());
    p1.add(lb1, BorderLayout.NORTH);
    p1.add("CENTER",p2);
    p1.add("SOUTH",p8);


    /*p1.add(lb2);
    p1.add(lb3);
    p1.add(lb4);
    p1.add(lb5);
    p1.add(tb6);
    */

    /*setLayout(new BorderLayout());
    add("NORTH",p1);
    add("CENTER",p2);
    add("SOUTH",p3);
    */



    p2 = new Panel();
    p2.setLayout(new BorderLayout());
    p2.add("NORTH",p3);
    p2.add("CENTER",p5);

    /*
    p2.add(tb7);
    p2.add(AmmountLabel);
    p2.setBackground(Color.pink);
    setLayout(new FlowLayout());
    add(p2);
    */


    StirJcheck = new Checkbox("Stir Fried Wide Rice : RM 2.00 per person",false);
    AbcJcheck = new Checkbox("ABC plus Mango Ice Cream with Pistachios : RM 3.00 per person",false);
    OysterJcheck = new Checkbox("Oysters Mombasa : Baked with Garlic Butter:RM 5.00 per person" ,false);
    OldJcheck= new Checkbox("Old Fashioned Banana Pudding : RM 2.50 per person",false);
    ThaiJcheck= new Checkbox("Thai Hot and Sour Shrimp Soup : RM 4.50 per person",false);



    p3 = new Panel();
    p3.setLayout(new BorderLayout());
    p3.add("NORTH",lb2);
    p3.add("CENTER",p4);
    p3.add("NORTH",tb6);

    /*
    p3.setForeground(Color.red);
    p3.setFont(fA);


    p3.add(StirJcheck);
    p3.add(AbcJcheck );
    p3.add(OysterJcheck);
    p3.add(OldJcheck);
    p3.add(ThaiJcheck);
    */

    /*setLayout(new BorderLayout(20,10));
    add(p3);
    */

    td8 = new Label(" ** PRICE ** ");
    td8.setBackground(Color.gray);

    td9 = new Label("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");


    td10 = new Label("PACKAGE : ");


    td11 = new Label("ADDITIONAL ORDER :");


    td12 = new Label(" TOTAL PRICE : ");




    p4 = new Panel();
    p4.setLayout(new GridLayout(3,0,0,10));
    p4.add(lb3);
    p4.add(lb4);
    p4.add(lb5);
    p4.setBackground(Color.yellow);
    p4.setFont(fA);


    /*
    p4.add(td8);
    p4.add(td9);
    p4.add(td10);
    p4.add(ct3);
    p4.add(td11);
    p4.add(ct1);
    p4.add(td12);
    p4.add(ct2);
    p4.setBackground(Color.GRAY);
    */

    /*setLayout(new FlowLayout(FlowLayout.LEFT,0,20));
    add(p4);
    */

    p5 = new Panel();
    p5.setLayout(new BorderLayout());
    p5.add("NORTH",p6);
    p5.add("CENTER",p7);

    p6= new Panel();
    p6.setLayout(new FlowLayout());
    p6.add(tb7);
    p6.add(AmmountLabel);

    p7 = new Panel();
    p7.setLayout(new GridLayout(5,0,0,0));
    p7.add(StirJcheck);
    p7.add(AbcJcheck);
    p7.add(OysterJcheck);
    p7.add(OldJcheck);
    p7.add(ThaiJcheck);

    p8 = new Panel();
    p8.setLayout(new BorderLayout());
    p8.add("NORTH",td8);
    p8.add("CENTER",p9);

    p9 = new Panel();
    p9.setLayout(new GridLayout());
    p9.add(td9);
    p9.add(td10);
    p9.add(td11);
    p9.add(td12);

    StirJcheck.addItemListener(this);
    AbcJcheck.addItemListener(this);
    OysterJcheck.addItemListener(this);
    OldJcheck.addItemListener(this);
    ThaiJcheck.addItemListener(this);

    }

    public void itemStateChanged(ItemEvent event) {


    double price =0.00;

    double total=PackagePric + price;


    NumberFormat nf = NumberFormat.getCurrencyInstance();


    int addAmount = Integer.parseInt(AmmountLabel.getText());



    if (StirJcheck.getState()) {

    price+= StirFriedCheck * addAmount;

    }


    if (AbcJcheck.getState()) {

    price+= AbcMango* addAmount;
    }


    if (OysterJcheck.getState()) {
    }
    price+= OystersMombasa * addAmount;



    if (OldJcheck.getState()) {

    price+= Oldfashioned * addAmount;

    }



    if (ThaiJcheck.getState()) {

    price+= Thaihot * addAmount;
    }



    ct1.setText(nf.format(price));
    ct2.setText(nf.format(total));
    ct3.setText(nf.format(PackagePric));

    }
    }
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2005
    Location
    UK, London
    Posts
    150
    Hi Laguna, you need to tell us what the problem is other wise we wont be able to help you.

Similar Threads

  1. Problems with While loop and GUI
    By I_Ethan_H in forum Java
    Replies: 1
    Last Post: 07-01-2006, 11:47 PM
  2. Gui builders... help starting
    By pedrotuga in forum Open Source
    Replies: 2
    Last Post: 07-26-2005, 08:28 AM
  3. Gui Freeze after re-connect
    By lstwil in forum Java
    Replies: 0
    Last Post: 05-29-2005, 09:54 AM
  4. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 07:53 AM
  5. Replies: 3
    Last Post: 03-17-2001, 04:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center