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

    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));

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

    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));

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

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

    fromchoice = new Choice();
    fromlabel.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));
    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));

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

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

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

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


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

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

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




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

    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
    Rep Power


    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
    Rep Power

Similar Threads

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