Results 1 to 5 of 5
  1. #1
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default Help with main method

    Hi I have finished the code but I can't give the main method because it wont compile with main ... can anybody help me ... This is the code :




    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;

    /**
    * Author: Fshmn
    * Date: Jul 20, 2008
    * Time: 2:38:38 AM
    */

    public class VinnysBar extends JApplet {

    private JPanel parentPanel, titlePanel, orderPanel, drinkPanel, icePanel;
    private JPanel drinkAndIcePanel, billPanel, bottomPanel;
    private JLabel lblTitle, lblDrink;
    private JButton btnBeer, btnTequila, btnVodka;
    private ButtonGroup grpIce, grpDrink;
    private JRadioButton radIce, radSomeIce, radNoIce;
    private JTextArea txtBill;
    private JButton btnCancelPrevious, btnNewOrder, btnCalculate;
    private double nTotal = 0, nSubTotal = 0, nPreviousPrice = 0;
    private String strPreviousDrink;



    /**
    * Constants
    */

    // Applet Size
    private final Dimension appletSize = new Dimension(500, 500);

    // PST tax rate
    private final double PST_RATE = 0.070;

    // GST tax rate
    private final double GST_RATE = 0.075;

    // Bottom buttons size
    private final Dimension BUTTON_SIZE = new Dimension(140, 35);

    // format for price
    private final DecimalFormat PRICE_FORMAT = new DecimalFormat("$###.##");

    // flag, if the user does not enter a number in the dialog
    private final int DIALOG_NOT_NUM = -1;

    // flag, if the user cancels the dialog
    private final int DIALOG_CANCEL = -2;


    public void init()
    {
    // set applet size
    this.setSize(appletSize);

    /**
    * Create Panels
    */
    parentPanel = new JPanel();
    titlePanel = new JPanel();
    orderPanel = new JPanel();
    drinkPanel = new JPanel();
    icePanel = new JPanel();
    drinkAndIcePanel = new JPanel();
    billPanel = new JPanel();
    bottomPanel = new JPanel();


    /**
    * Set Panel Borders
    */
    // Bill's Border
    TitledBorder billBorder = new TitledBorder(BorderFactory.createEtchedBorder(),
    "Bill", TitledBorder.LEFT, TitledBorder.CENTER);
    billPanel.setBorder(billBorder);

    // Order's Border
    TitledBorder orderBorder = new TitledBorder(BorderFactory.createEtchedBorder(),
    "Order", TitledBorder.LEFT, TitledBorder.CENTER);
    orderPanel.setBorder(orderBorder);


    // Ice Border
    TitledBorder iceBorder = new TitledBorder(BorderFactory.createEtchedBorder(),
    "Ice", TitledBorder.LEFT, TitledBorder.CENTER);
    icePanel.setBorder(iceBorder);


    /**
    * Create Components
    */
    // Title
    lblTitle = new JLabel("- VINNY'S BAR -");
    lblTitle.setFont (new Font ("Book Antiqua", Font.BOLD, 18));
    lblTitle.setAlignmentX(Component.CENTER_ALIGNMENT) ;
    titlePanel.add(lblTitle);

    // Drinks
    grpDrink = new ButtonGroup();
    btnBeer = new JButton("Beer");
    btnTequila = new JButton("Tequila");
    btnVodka = new JButton("Vodka");
    grpDrink.add(btnBeer);
    grpDrink.add(btnTequila);
    grpDrink.add(btnVodka);
    btnBeer.addActionListener(new btnBeerListener());
    btnTequila.addActionListener(new btnTequilaListener());
    btnVodka.addActionListener(new btnVodkaListener());
    drinkPanel.add(btnBeer);
    drinkPanel.add(btnTequila);
    drinkPanel.add(btnVodka);


    // drink image
    lblDrink = new JLabel("", new ImageIcon(
    getClass().getResource("drink.gif")), SwingConstants.CENTER);
    drinkAndIcePanel.add(lblDrink, BorderLayout.CENTER);


    // Ice
    radIce = new JRadioButton("With a lot of ice", false);
    radSomeIce = new JRadioButton("With some ice", true);
    radNoIce = new JRadioButton("Without ice", false);
    grpIce = new ButtonGroup();
    grpIce.add(radIce);
    grpIce.add(radSomeIce);
    grpIce.add(radNoIce);
    icePanel.add(radIce);
    icePanel.add(radSomeIce);
    icePanel.add(radNoIce);

    // Bill
    txtBill = new JTextArea();
    txtBill.setEditable(false);
    txtBill.setLineWrap(true);
    initializeBill();
    billPanel.add(txtBill, BorderLayout.CENTER);
    billPanel.add(new JScrollPane(txtBill), BorderLayout.CENTER);


    // Calculate
    btnCalculate = new JButton("Calculate");
    btnCalculate.addActionListener(new btnCalculateListener());
    btnCalculate.setEnabled(false);
    bottomPanel.add(btnCalculate, BorderLayout.CENTER);

    // Cancel Previous
    btnCancelPrevious = new JButton("Cancel Previous");
    btnCancelPrevious.addActionListener(new btnCancelPreviousListener());
    btnCancelPrevious.setPreferredSize(BUTTON_SIZE);
    btnCancelPrevious.setEnabled(false);
    bottomPanel.add(btnCancelPrevious, BorderLayout.EAST);

    ....

  2. #2
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    Why do you need a main Method in an Applet?

  3. #3
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default

    Yes I need for Applet but I will appriciate if you can make one for sdk java ...

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by eliCanzee View Post
    Yes I need for Applet but I will appriciate if you can make one for sdk java ...
    No, as the first reply implied, you don't need a main method for an applet. You may wish to read the applet tutorial at the Sun Java tutorial site.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,185
    Rep Power
    20

    Default

    Also, just out of curiosity, what does this have to do with databases?

Similar Threads

  1. calling method from main method
    By bob_bee in forum New To Java
    Replies: 4
    Last Post: 10-02-2009, 06:30 PM
  2. Where do I put main method?
    By jerryrice80 in forum New To Java
    Replies: 4
    Last Post: 09-16-2009, 09:23 PM
  3. Main method here to :S:S hlp pls
    By eliCanzee in forum AWT / Swing
    Replies: 6
    Last Post: 05-27-2009, 05:45 AM
  4. Help me for main method
    By eliCanzee in forum AWT / Swing
    Replies: 1
    Last Post: 05-26-2009, 01:43 PM
  5. main method
    By eva in forum New To Java
    Replies: 5
    Last Post: 12-19-2007, 10:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •