Im trying to create a GUI that Converts Meters to Feet and Visa Versa and you select which you are doing by a drop down box.
This is my code so far I'm having trouble with the converting bit.
Im hoping someone might be able to point me in the right direction as so far everything i have tried has not been working.
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Exercise5 extends JFrame implements ActionListener {
private JPanel thePanel = new JPanel();
private JLabel EnterValue = new JLabel("Enter Value to Convert:");
private JTextField TextField = new JTextField(10);
String[] Choose = { "Meters to Feet", "Feet to Meters" };
private JComboBox DropBox = new JComboBox(Choose);
private JButton Convert = new JButton("Convert");
private JLabel ResultIs = new JLabel("Result is:");
private JLabel Result = new JLabel("0");
Exercise5(String s) {
super(s);
getContentPane().setLayout(new GridLayout(4, 2));
DropBox.setSelectedIndex(1);
getContentPane().add(EnterValue);
getContentPane().add(TextField);
getContentPane().add(DropBox);
getContentPane().add(Convert);
getContentPane().add(ResultIs);
getContentPane().add(Result);
setSize(400, 250);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if ("convert".equals(e.getActionCommand())) {
}
}
public static void main(String[] args) {
Exercise5 thePanel = new Exercise5("Converter");
}
}
Thanks in Advance.

New Topic/Question
Reply



MultiQuote



|