Results 1 to 4 of 4
- 11-09-2010, 12:34 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
Currency Converter Applet Help...
Hello there, I am in the process of creating a currency converter applet. I have the layout done and the applet runs in my web browser but I am having trouble coding the calculation for the converter. Could somebody point me in the right direction please, here is my code...
Thanks in advance.Java Code:import java.awt.*; import javax.swing.*; import java.awt.event.*; public class CurrencyConverter extends JApplet implements ActionListener { // applet title JLabel lblTitle = new JLabel ("Currency Converter Applet"); // label for promt input + input box JLabel lblinput = new JLabel("Enter a Value GBP"); JTextField txtinput = new JTextField(10); // Labels to display name of currency converter JLabel lbldollar = new JLabel("US Dollars = "); JLabel lbleuro = new JLabel("Euro = "); JLabel lblyen = new JLabel("Yen = "); JLabel lblpound = new JLabel("GBP = "); // Labels to display value of currency converted JLabel lbldollaramount = new JLabel("0"); JLabel lbleuroamount = new JLabel("0"); JLabel lblyenamount = new JLabel("0"); JLabel lblpoundamount = new JLabel("0"); // button convert + clear JButton btnconvert = new JButton ("Convert"); JButton btnclear = new JButton ("Clear"); public void init() { // this is a workaround for a security conflict with some browsers // including some versions of Netscape & Internet Explorer which do // not allow access to the AWT system event queue which JApplets do // on startup to check access. May not be necessary with your browser. JRootPane rootPane = this.getRootPane(); rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); // provide any initialisation necessary for your JApplet } public void start() { // provide any code required to run each time // web page is visited display(); } public void display() { /** * set font size and colour of labels */ // lblinput lblinput.setFont(new Font("Algerian", Font.BOLD, 18)); lblinput.setForeground(Color.black); txtinput.setFont(new Font("Algerian", Font.BOLD, 18)); txtinput.setForeground(Color.black); //dollar lbldollar.setFont(new Font("Algerian", Font.BOLD, 18)); lbldollar.setForeground(Color.black); lbldollaramount.setFont(new Font("Algerian", Font.BOLD, 18)); lbldollaramount.setForeground(Color.black); //euro lbleuro.setFont(new Font("Algerian", Font.BOLD, 18)); lbleuro.setForeground(Color.black); lbleuroamount.setFont(new Font("Algerian", Font.BOLD, 18)); lbleuroamount.setForeground(Color.black); //yen lblyen.setFont(new Font("Algerian", Font.BOLD, 18)); lblyen.setForeground(Color.black); lblyenamount.setFont(new Font("Algerian", Font.BOLD, 18)); lblyenamount.setForeground(Color.black); //gbp lblpound.setFont(new Font("Algerian", Font.BOLD, 18)); lblpound.setForeground(Color.black); lblpoundamount.setFont(new Font("Algerian", Font.BOLD, 18)); lblpoundamount.setForeground(Color.black); //buttons font, size, colour and attach action listener btnconvert.setFont(new Font("Algerian", Font.BOLD, 18)); btnconvert.setForeground(Color.black); btnconvert.addActionListener(this); btnclear.setFont(new Font("Algerian", Font.BOLD, 18)); btnclear.setForeground(Color.black); btnclear.addActionListener(this); /** * add items to main panel */ Container content = getContentPane(); // set layout content.setLayout(new GridLayout(6,2)); // set colour content.setBackground(Color.red); // (input) content.add(lblinput); content.add(txtinput); txtinput.setText("0"); // (dollar) content.add(lbldollar); content.add(lbldollaramount); //(euro) content.add(lbleuro); content.add(lbleuroamount); //(yen) content.add(lblyen); content.add(lblyenamount); //(pound) content.add(lblpound); content.add(lblpoundamount); content.add(btnclear); content.add(btnconvert); } public void actionPerformed(ActionEvent event) { if(event.getSource()==btnclear) {txtinput.setText("0"); lbldollaramount.setText("0"); lbleuroamount.setText("0"); lblyenamount.setText("0"); lblpoundamount.setText("0");} if(event.getSource()==btnconvert) {txtinput.setText("1"); lbldollaramount.setText("1"); lbleuroamount.setText("1"); lblyenamount.setText("1"); lblpoundamount.setText("1");} } }
- 11-09-2010, 12:54 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
On what you stuck with in currency conversion?
- 11-09-2010, 01:56 PM #3
Rather looks like this thread will go the same way as the OP's earlier thread
Java Slideshow in BlueJ...Help!
db
- 11-09-2010, 05:27 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Currency Converter!!!!
By Pascal Nouma in forum AWT / SwingReplies: 2Last Post: 04-02-2009, 07:23 AM -
Formatting a number to currency
By Java Tip in forum java.textReplies: 0Last Post: 04-16-2008, 10:59 PM -
Setting currency
By Java Tip in forum Java TipReplies: 0Last Post: 11-16-2007, 02:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks