| | |
how to create currency converter
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2008
Posts: 8
Reputation:
Solved Threads: 0
/****************************************************************/
/* jFrame */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
/**
* Summary description for jFrame
*
*/
public class jFrame extends JFrame
{
// Variables declaration
private JLabel jLabel1;
private JLabel jLabel2;
private JTextField jTextField1;
private JTextField jTextField2;
private JList jList3;
private JScrollPane jScrollPane1;
private JList jList4;
private JScrollPane jScrollPane2;
private JButton jButton1;
private JButton jButton2;
private JPanel contentPane;
// End of variables declaration
public jFrame()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jTextField1 = new JTextField();
jTextField2 = new JTextField();
jScrollPane1 = new JScrollPane();
jScrollPane2 = new JScrollPane();
jButton1 = new JButton();
jButton2 = new JButton();
contentPane = (JPanel)this.getContentPane();
//
// jLabel1
//
jLabel1.setText("From:");
//
// jLabel2
//
jLabel2.setText("To:");
//
// jTextField1
//
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
}
});
//
// jTextField2
//
jTextField2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField2_actionPerformed(e);
}
});
//
// jList3
String[] listcountriescurrency = { "USD:Utd States$", "EURO:Euro", "GBP:Utd Kingdom Pnd", "JPY:Japan Yen",
"CAD:Canada$", "AUD:Australia$", "CHF:Switzerland Fr", "AED:Utd Arab Emirates Dhs" };
Container contentpane;
contentpane = getContentPane();
contentpane.setLayout(new FlowLayout());
jList3 = new JList(listcountriescurrency);
jList3.setSelectedIndex(0);
jList3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//
jList3.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e)
{
jList3_valueChanged(e);
}
});
//
// jScrollPane1
//
jScrollPane1.setViewportView(jList3);
//
// jList4
contentpane = getContentPane();
contentpane.setLayout(new FlowLayout());
jList4 = new JList(listcountriescurrency);
jList4.setSelectedIndex(0);
jList4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//
jList4.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e)
{
jList4_valueChanged(e);
}
});
//
// jScrollPane2
//
jScrollPane2.setViewportView(jList4);
//
// jButton1
//
jButton1.setText("Convert");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
//
// jButton2
//
jButton2.setText("Close");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
String message = "Thank you for using Our Currency Convertor";
JOptionPane.showMessageDialog(null,message);
System.exit(0);
}
});
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jLabel1, 9,17,60,18);
addComponent(contentPane, jLabel2, 178,19,60,18);
addComponent(contentPane, jTextField1, 4,225,89,22);
addComponent(contentPane, jTextField2, 186,226,80,22);
addComponent(contentPane, jScrollPane1, 7,42,152,166);
addComponent(contentPane, jScrollPane2, 173,42,154,167);
addComponent(contentPane, jButton1, 98,224,83,25);
addComponent(contentPane, jButton2, 270,225,73,25);
//
// jFrame
//
this.setTitle("Currency Converter Application");
this.setLocation(new Point(29, 3));
this.setSize(new Dimension(356, 287));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jTextField2_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jList3_valueChanged(ListSelectionEvent e)
{
System.out.println("\njList3_valueChanged(ListSelectionEvent e) called.");
if(!e.getValueIsAdjusting())
{
Object o = jList3.getSelectedValue();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected
}
}
private void jList4_valueChanged(ListSelectionEvent e)
{
System.out.println("\njList4_valueChanged(ListSelectionEvent e) called.");
if(!e.getValueIsAdjusting())
{
Object o = jList4.getSelectedValue();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected
}
}
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jButton2_actionPerformed(ActionEvent e)
{
System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
//
// TODO: Add any method code to meet your needs in the following area
//
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//======================================================================//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new jFrame();
}
//= End of Testing =
}i wish this is the correct way to post the codes
•
•
Join Date: Dec 2008
Posts: 8
Reputation:
Solved Threads: 0
hi friends
first of all plz excuse my bad English...Actually English is my second language..
my question is where i should put the codes that will convert the currency? and what is the codes??
to be honest i have my friend project but i don’t wanna copy it i want to understand the codes...so plz can u give me simple codes and where i should put it??
thanks friends really u r very helpful
first of all plz excuse my bad English...Actually English is my second language..
my question is where i should put the codes that will convert the currency? and what is the codes??
to be honest i have my friend project but i don’t wanna copy it i want to understand the codes...so plz can u give me simple codes and where i should put it??
thanks friends really u r very helpful
![]() |
Other Threads in the Java Forum
- Previous Thread: does java support Multiple inheritence via interfaces
- Next Thread: Help in java code
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui helpwithhomework html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows






