Results 1 to 4 of 4
  1. #1
    eiramae is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Question help! Gridlayout

    I was trying to make a row and column to my applet.... but nothings happen.... i can't figure out what's really the problem... please help!....


    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import javax.swing.JPanel;
    import javax.swing.BorderFactory;

    public class CurrencyConverter extends Applet implements ActionListener

    {

    Label header;

    Label amountlabel;
    TextField amountfield;

    Label fromlabel;
    Choice fromchoice;
    double[] value={1.00000,43.5241,101.830,4.85908,10.1931,298 0.70,29.8823,1.45021,1.45006,5.48783,0.43355,17.96 77,5.52844,11.3770,4.40437,4.85908,1.44881,252.415 ,201.184,117.540,0.58340,1,434.32,0.52105,2.55983, 29.8823,45.3683,0.31801,11.7450,5.85440,2.91617,14 8.510,31,434.3,29.2834,76.4078,22.3162,177.516,123 .253,6.49595,0.97210,1.59249,7.85630,0.62392,76.40 78};

    Button calculate;

    Label exchangeratelabel;
    TextField exchangeratefield;

    Label calcamtlabel;
    TextField calcamtfield;


    public void init()
    {
    setLayout(new GridLayout(5,2));
    setBackground(Color.green);

    header = new Label("Currency Conversion Calculator");
    header.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(header);


    amountlabel = new Label("Amount of Dollars to be Exchange");
    amountlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(amountlabel);

    amountfield = new TextField(15);
    amountfield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(amountfield);

    fromlabel = new Label("Convert From:");
    fromlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(fromlabel);

    fromchoice = new Choice();
    fromlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(fromchoice);
    fromchoice.addItem("United States US Dollar (USD)");
    fromchoice.addItem("Philippines Philippine Peso (PHP)");
    fromchoice.addItem("Albania Albanian Lek (ALL)");
    fromchoice.addItem("Andorra Andorran Franc (ADF)");
    fromchoice.addItem("Austria Austrian Schilling (ATS)");
    fromchoice.addItem("Belarus Belarusian Ruble (BYR)");
    fromchoice.addItem("Belgium Belgian Franc (BEF)");
    fromchoice.addItem("Bosnia Bosnia Mark (BAM)");
    fromchoice.addItem("Bulagria Bulgarian Lev (BGN)");
    fromchoice.addItem("Cyprus Cypriot Pound (CYP)");
    fromchoice.addItem("Czech Republic Czech Koruna (CZK)");
    fromchoice.addItem("Denmark Danish Krone (DKK)");
    fromchoice.addItem("Estonia Estonian Kroon (EEK)");
    fromchoice.addItem("Findland Finnish Markka (FIM)");
    fromchoice.addItem("Germany German Mark (DEM)");
    fromchoice.addItem("Greece Greek Drachma (GRD)");
    fromchoice.addItem("Hungary Hungarian Forint (HUF)");
    fromchoice.addItem("Iceland Iceland Krona (ISK)");
    fromchoice.addItem("Ireland Irish Punt (IEP)");
    fromchoice.addItem("Italy Italian Lira (ITL)");
    fromchoice.addItem("Latvia Latvian Lats (LVL)");
    fromchoice.addItem("Lithuania Lithuanian Litas (LTL)");
    fromchoice.addItem("Luxemburg Luxembourg Franc (LUF)");
    fromchoice.addItem("Macedonia Macedonian Denar (MKD)");
    fromchoice.addItem("Malta Maltese Lira (MTL)");
    fromchoice.addItem("Moldova Moldovan Leu (MDL)");
    fromchoice.addItem("Norway Norwegian Kroner (NOK)");
    fromchoice.addItem("Poland Polish Zloty (PLN)");
    fromchoice.addItem("Portugal Portuguese Escudo (PTE)");
    fromchoice.addItem("Romania Romanian Lei (ROL)");
    fromchoice.addItem("Russia Russian Rouble (RUB)");
    fromchoice.addItem("Serbia Serbian Dinar (RSD)");
    fromchoice.addItem("Slovakia Slovak Koruna (SKK)");
    fromchoice.addItem("Slovenia Slovenian Tolar (SIT)");
    fromchoice.addItem("Spain Spanish Peseta (ESP)");
    fromchoice.addItem("Sweden Swedish Krona (SEK)");
    fromchoice.addItem("Switzerland Swiss Franc (CHF)");
    fromchoice.addItem("Turkey Turkish Lira (TRY)");
    fromchoice.addItem("Ukraine Ukraine Hryvnia (UAH)");
    fromchoice.addItem("United Kingdom British Pound (GBP)");
    fromchoice.addItem("Yugoslavia Yugoslav Dinar (YUN)");

    calculate = new Button("Calculate");
    calculate.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(calculate);
    calculate.addActionListener(this);

    exchangeratelabel = new Label("Exchange Rate");
    exchangeratelabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(exchangeratelabel);

    exchangeratefield = new TextField(15);
    exchangeratefield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(exchangeratefield);

    calcamtlabel = new Label("Calculated Amount");
    calcamtlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(calcamtlabel);

    calcamtfield = new TextField(15);
    calcamtfield.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    add(calcamtfield);



    }



    public void actionPerformed(ActionEvent e)
    {
    double cal,total;

    int actval = fromchoice.getSelectedIndex();
    total = value[actval];

    int af = Integer.parseInt(amountfield.getText());

    cal=af*total;

    exchangeratefield.setText(""+total);
    calcamtfield.setText(""+cal);


    }
    }

  2. #2
    javaforum$ is offline Member
    Join Date
    Feb 2011
    Posts
    7
    Rep Power
    0

    Default what's the problem??

    what do you mean by nothing happens???
    can you be more specific in problem statement than code giving.

  3. #3
    eiramae is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default

    thank you for fast reply.....

    i'm sorry.... my fault... my browser doesn't seem to refresh.... but i had another problem.... the label currency conversion calculator and the button calculate should be in the center..... and the label amount of dollars to be exchange and the text field should be in one line.... and how can i minimize the size of the text field same size of the choice....
    Attached Thumbnails Attached Thumbnails help! Gridlayout-output1.jpg  

  4. #4
    eiramae is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

Similar Threads

  1. how to control the GridLayout
    By amro in forum New To Java
    Replies: 8
    Last Post: 10-31-2010, 04:45 PM
  2. SWT GridLayout Demo
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 04:48 PM
  3. SWT GridLayout
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:04 AM
  4. GridLayout with animation?
    By tojas in forum AWT / Swing
    Replies: 3
    Last Post: 11-12-2007, 10:16 PM
  5. Gridlayout
    By Marty in forum AWT / Swing
    Replies: 2
    Last Post: 05-31-2007, 11:48 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
  •