Help needed to modify the program

following code is a curency convrter. I want to put standard conversion rates ? = 1.46859 euros and ? = 1.88732 dollars so that when pound amount is put the other amounts are generated automatically. How can I do so?

import java.awt.*;

import java.awt.event.*;

import java.applet.Applet;

import javax.swing.*;

class CCGUIextends Appletimplements ActionListener

{

JLabellabel_1;

JLabelentamtLabel;

JLabelconamtLabel;

JTextField entamtField;

JTextField conamtField;

JLabelfromLabel;

JLabeltoLabel;

JComboBox fromComboBox;

JComboBox toComboBox;

JButtonconButton;

publicvoid init()

{

//CCGUILayout customLayout = new CCGUILayout();

//setFont(new Font("Helvetica", Font.PLAIN, 12));

//setLayout(customLayout);

setLayout(new GridLayout(5,2,3,3));

//label_1 = new JLabel("Currency Converter");

//add(label_1);

entamtLabel =new JLabel("Pounds");

add(entamtLabel);

entamtField =new JTextField("");

add(entamtField);

conamtLabel =new JLabel("Dollars");

add(conamtLabel);

conamtField =new JTextField("");

add(conamtField);

conamtLabel =new JLabel("Euros");

add(conamtLabel);

conamtField =new JTextField("");

add(conamtField);

conButton =new JButton("Convert");

conButton.addActionListener(this);

add(conButton);

//setSize(getPreferredSize());

}

publicvoid actionPerformed(ActionEvent ae)

{

//Convert con = new Convert();

if (ae.getSource() == conButton)

{

double d = Double.parseDouble(entamtField.getText());

double r = d;

conamtField.setText(""+r);

}

}

}

class CCGUILayoutimplements LayoutManager

{

public CCGUILayout()

{

}

publicvoid layoutContainer(Container parent)

{

}

publicvoid addLayoutComponent(String name, Component comp)

{

}

publicvoid removeLayoutComponent(Component comp)

{

}

public Dimension preferredLayoutSize(Container parent)

{

Dimension dim =new Dimension(0, 0);

Insets insets = parent.getInsets();

dim.width = 321 + insets.left + insets.right;

dim.height = 149 + insets.top + insets.bottom;

return dim;

}

public Dimension minimumLayoutSize(Container parent)

{

Dimension dim =new Dimension(0, 0);

return dim;

}

publicstaticvoid main(String args[])

{

CCGUI applet =new CCGUI();

Frame window =new Frame("Currency Converter");

window.setBounds(10,10,300,144);

window.addWindowListener(new WindowAdapter()

{

publicvoid windowClosing(WindowEvent e)

{

System.exit(0);

}

});

applet.init();

window.add("Center", applet);

//window.pack();

window.setVisible(true);

}

}

[5756 byte] By [crystalaruna] at [2007-11-26 21:33:45]
# 1
want to put standard conversion rates ? = 1.46859 euros and ? = 1.88732 dollars so that when pound amount is put the other amounts are generated automatically. How can I do so?
crystalaruna at 2007-7-10 3:14:48 > top of Java-index,Java Essentials,Java Programming...
# 2
ok can somebody atleat show me if i would like the user to input only pound rates and other boxes should be used only for output and no input can be entered in euros or dollars.THANKS FOR YOUR TIME
crystalaruna at 2007-7-10 3:14:48 > top of Java-index,Java Essentials,Java Programming...
# 3

You can make it work both ways, have different JTextFields for the values and attach listeners to them. When you get an event (Something like TextListener if I recall correctly) you can fill the other textfields with proper values and keep the user from entering letters or other illegal characters.

-Kayaman-a at 2007-7-10 3:14:49 > top of Java-index,Java Essentials,Java Programming...
# 4
ah... sorry... but textlistener is not the thing i suppose... can anyone help me please... :-)
crystalaruna at 2007-7-10 3:14:49 > top of Java-index,Java Essentials,Java Programming...
# 5
i want to add a clear button in this application which clears all the inputs and outputs. can anybody complete the code plz...conditionButton = new JButton("Clear");conditionButton..............add(conditionButton);
crystalaruna at 2007-7-10 3:14:49 > top of Java-index,Java Essentials,Java Programming...