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

    Question help! JPanel....

    i don't know what's wrong with my codings, because nothing happens in my applet..... it turns blank.... pls... help....
    here's my code

    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;

    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();

    public void init()

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

    panel2.setLayout(new FlowLayout(FlowLayout.CENTER));
    panel2.setLayout(new GridLayout(2,2));
    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)");

    panel3.setLayout(new FlowLayout(FlowLayout.CENTER));
    calculate = new Button("Calculate");
    calculate.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD | java.awt.Font.ITALIC, 12));

    panel4.setLayout(new FlowLayout(FlowLayout.CENTER));
    panel4.setLayout(new GridLayout(2,2));
    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());



    Attached Thumbnails Attached Thumbnails help! JPanel....-output.jpg  

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Were do you add any components to the JApplet itself, or more accurately, its contentPane?

    Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
      // your code goes here
      // notice how the top and bottom tags are different
    Much luck!

Similar Threads

  1. Jpanel in
    By archanaanbu in forum Java Applets
    Replies: 1
    Last Post: 02-11-2011, 06:10 PM
  2. Placing a new JPanel over a paint overriden JPanel
    By Tanshaydar in forum AWT / Swing
    Replies: 4
    Last Post: 12-08-2010, 07:00 PM
  3. Replies: 1
    Last Post: 11-09-2010, 10:28 AM
  4. .add to a JPanel
    By harrier in forum NetBeans
    Replies: 11
    Last Post: 07-13-2010, 11:24 AM
  5. I need some help with JPanel
    By bantes in forum AWT / Swing
    Replies: 7
    Last Post: 11-03-2009, 08:58 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