I'm having trouble finding a problem in this program that supposedly converts currencies, is it possible to find some help from specialists in the Java programming language ...?
the codes here:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.* ;
public class CurrencyConvertor extends JFrame
{
private JLabel jLabelFrom;
private JLabel jLabelTo;
private JTextField jTextFieldFrom;
private JTextField jTextFieldTo;
private JList jListFrom;
private JList jListTo;
private JButton jButtonCovert;
private JButton jButtonClose;
private JPanel contentPane;
public CurrencyConvertor()
{
super();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
ArrayList arr;
jLabelFrom = new JLabel();
jLabelTo = new JLabel();
jTextFieldFrom = new JTextField();
jTextFieldTo = new JTextField();
jListFrom = new JList();
jListTo = new JList();
jButtonCovert = new JButton();
jButtonClose = new JButton();
contentPane = (JPanel)this.getContentPane();
jLabelFrom.setText("From:");
jLabelTo.setText("To:");
jTextFieldFrom.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextFieldFrom_actionPerformed(e);
}
});
jTextFieldTo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextFieldTo_actionPerformed(e);
}
});
String[]ListFrom = new String[8];
ListFrom[0]="USD:Utd States $";
ListFrom[1]="EURO:Euro";
ListFrom[2]="GBP:Utd Kingdom Pnd";
ListFrom[3]="JPY:Japan Yen";
ListFrom[4]="CAD:Canada $";
ListFrom[5]="AUD:Australia $";
ListFrom[6]="CHF:Switzerland Fr";
ListFrom[7]="AED:Utd Arab Emirates Dhs";
Container contentpane;
contentpane = getContentPane();
contentpane.setLayout(new FlowLayout());
jListFrom = new JList(ListFrom);
jListFrom.setSelectedIndex(0);
jListFrom.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jListFrom.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e)
{
jListFrom_valueChanged(e);
}
});
String[]ListTo = new String[8];
ListTo[0]="USD:Utd States $";
ListTo[1]="EURO:Euro";
ListTo[2]="GBP:Utd Kingdom Pnd";
ListTo[3]="JPY:Japan Yen";
ListTo[4]="CAD:Canada $";
ListTo[5]="AUD:Australia $";
ListTo[6]="CHF:Switzerland Fr";
ListTo[7]="AED:Utd Arab Emirates Dhs";
contentpane = getContentPane();
contentpane.setLayout(new FlowLayout());
jListTo = new JList(ListTo);
jListTo.setSelectedIndex(0);
jListTo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jListTo.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e)
{
jListTo_valueChanged(e);
}
});
jButtonCovert.setText("Convert");
jButtonCovert.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButtonCovert_actionPerformed(e);
}
});
jButtonClose.setText("Close");
jButtonClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButtonClose_actionPerformed(e);
}
});
contentPane.setLayout(null);
addComponent(contentPane, jLabelFrom, 17,25,60,18);
addComponent(contentPane, jLabelTo, 227,27,60,18);
addComponent(contentPane, jTextFieldFrom, 13,260,100,26);
addComponent(contentPane, jTextFieldTo, 222,258,100,29);
addComponent(contentPane, jListFrom, 13,50,196,184);
addComponent(contentPane, jListTo, 228,51,191,185);
addComponent(contentPane, jButtonCovert, 124,258,83,28);
addComponent(contentPane, jButtonClose, 338,258,83,28);
this.setTitle("CurrencyConvertor - extends JFrame");
this.setLocation(new Point(0, 2));
this.setSize(new Dimension(455, 344));
}
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
private void jTextFieldFrom_actionPerformed(ActionEvent e)
{
System.out.println("\njTextFieldFrom_actionPerformed(ActionEvent e) called.");
}
private void jTextFieldTo_actionPerformed(ActionEvent e)
{
System.out.println("\njTextFieldTo_actionPerformed(ActionEvent e) called.");
}
private void jListFrom_valueChanged(ListSelectionEvent e)
{
System.out.println("\njListFrom_valueChanged(ListSelectionEvent e) called.");
if(!e.getValueIsAdjusting())
{
Object o = jListFrom.getSelectedValue();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
}
}
private void jListTo_valueChanged(ListSelectionEvent e)
{
System.out.println("\njListTo_valueChanged(ListSelectionEvent e) called.");
if(!e.getValueIsAdjusting())
{
Object o = jListTo.getSelectedValue();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
}
}
private void jButtonCovert_actionPerformed(ActionEvent e)
{
System.out.println("\njButtonCovert_actionPerformed(ActionEvent e) called.");
jTextFieldFrom.getText();
int jTextFieldFrom = Integer.ParseInt();
String jTextFieldFrom = "RATES.txt";
String content = new String ("");
FileInputStream file = new FileInputStream(jTextFieldFrom);
file.read();
jTextFieldTo.getText();
int jTextFieldTo = Integer.ParseInt();
String jTextFieldFrom = "ConversionLog.txt";
FileOutputStream file = new FileOutputStream(jTextFieldFrom);
file.write();
}
private void jButtonClose_actionPerformed(ActionEvent e)
{
System.out.println("\njButtonClose_actionPerformed(ActionEvent e) called.");
String message = "Thank you for using Our Currency Convertor";
JOptionPane.showMessageDialog(null,message);
System.exit(0);
}
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 CurrencyConvertor();
}
}