import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.event.*;
public class operator
{
private Container c;
ConvertArray conArr;
JComboBox length1, length2, volume1, volume2, mass1, mass2, tempurate1, tempurate2, currency1, currency2;
String first, second;
int num = 0;
JButton Ok = new JButton ("Convert");
JButton cancel = new JButton ("cancel");
JFrame ConLength = new JFrame ("converting length");
JFrame ConVolume = new JFrame ("Converting Volume");
public operator (ConvertArray i)
{
conArr = i;
}
public void Length ()
{
ConLength.setSize (500,400);
ConLength.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
ConLength.setVisible (true);
JLabel addinfo = new JLabel ("Please select the first box for the value you are going to enter");
JLabel addinfo2 = new JLabel ("select the second value for the value you want to convert to");
JLabel addinfo3 = new JLabel ("Then click ok");
JLabel addinfo4 = new JLabel ("enter here:");
length1 = new JComboBox ();
length1.addItem ("cm");
length1.addItem ("inch");
length1.addItem ("feet");
length1.addItem ("meters");
length1.setBounds (70, 130, 150, 20);
length2 = new JComboBox ();
length2.addItem ("cm");
length2.addItem ("inch");
length2.addItem ("feet");
length2.addItem ("meters");
length2.setBounds (250, 130, 150, 20);
final JTextArea enter = new JTextArea (20, 130);
enter.setBounds (250, 200, 150, 20);
addinfo.setBounds (10, 5, 400, 20);
addinfo2.setBounds (10, 25, 400, 20);
addinfo3.setBounds (10, 45, 400, 20);
addinfo4.setBounds (70,200,150,20);
Ok.setBounds (100, 275, 100, 50);
cancel.setBounds (250, 275, 100, 50);
c = ConLength.getContentPane ();
c.setLayout (null);
c.add(addinfo);
c.add(addinfo2);
c.add(addinfo3);
c.add (addinfo4);
c.add(length1);
c.add(length2);
c.add(enter);
c.add(Ok);
c.add(cancel);
ConLength.setVisible (true);
Ok.addActionListener (
new ActionListener()
{
public void itemStateChange (ItemEvent event, ItemEvent event2)
{
first = event.getItem ().toString ();
second = event2.getItem ().toString ();
ConLength.dispose ();
}
public void ActionPerformed (ActionEvent event)
{
String a = enter.getText ();
num = Integer.parseInt (a);
if ( first == "length")
{
}
}
}
);
cancel1 ();
}
private void cancel1 ()
{
cancel.addActionListener (
new ActionListener ()
{
public void actionPerformed (ActionEvent event)
{
ConLength.dispose ();
}
}
);
}
// to convert voulme
public void Voulme ()
{
ConVolume.setSize (500,400);
ConVolume.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
ConVolume.setVisible (true);
JLabel addinfo = new JLabel ("Please select the first box for the value you are going to enter");
JLabel addinfo2 = new JLabel ("select the second value for the value you want to convert to");
JLabel addinfo3 = new JLabel ("Then click ok");
JLabel addinfo4 = new JLabel ("enter here:");
volume1 = new JComboBox ();
volume1.addItem ("Litres");
volume1.addItem ("Gallons");
volume1.addItem ("Oz.");
volume1.addItem ("Millilitres");
volume1.setBounds (70, 130, 150, 20);
volume2 = new JComboBox ();
volume2.addItem ("Litres");
volume2.addItem ("Gallons");
volume2.addItem ("Oz.");
volume2.addItem ("Millilitres");
volume2.setBounds (250, 130, 150, 20);
final JTextArea enter = new JTextArea (20, 130);
enter.setBounds (250, 200, 150, 20);
addinfo.setBounds (10, 5, 400, 20);
addinfo2.setBounds (10, 25, 400, 20);
addinfo3.setBounds (10, 45, 400, 20);
addinfo4.setBounds (70,200,150,20);
Ok.setBounds (100, 275, 100, 50);
cancel.setBounds (250, 275, 100, 50);
c = ConVolume.getContentPane ();
c.setLayout (null);
c.add(addinfo);
c.add(addinfo2);
c.add(addinfo3);
c.add (addinfo4);
c.add(length1);
c.add(length2);
c.add(enter);
c.add(Ok);
c.add(cancel);
ConVolume.setVisible (true);
Ok.addActionListener (
new ActionListener()
{
public void itemStateChange (ItemEvent event, ItemEvent event2)
{
first = event.getItem ().toString ();
second = event2.getItem ().toString ();
}
public void ActionPerformed (ActionEvent event)
{
String a = enter.getText ();
num = Integer.parseInt (a);
if ( first == "Litres")
{
}
ConVolume.dispose ();
}
}
);
cancel2 ();
}
private void cancel2 ()
{
cancel.addActionListener (
new ActionListener ()
{
public void actionPerformed (ActionEvent event)
{
ConVolume.dispose ();
}
}
);
}
}