import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import javax.swing.ButtonGroup;
import java.awt.event.*;
public class tempConv extends JFrame{
public static void main(String[] args) {
tempConv item = new tempConv();
// TODO Auto-generated method stub
}
tempConv()
{
super ("Temperature Converter");
new JFrame();
JRadioButton incel;
JRadioButton infah;
JRadioButton inkel;
JRadioButton outcel;
JRadioButton outfah;
JRadioButton outkel;
JTextField tempInput;
JTextField tempOutput;
inCalc inTfield;
double outtemp = 0;
double intemp = 0;
string intext;
JPanel input = new JPanel();
input.add(new JLabel("Input:"));
input.add(tempInput = new JTextField(7));
JPanel output = new JPanel();
output.add(new JLabel("Output:"));
output.add(tempOutput = new JTextField(7));
JPanel Ftemp = new JPanel();
Ftemp.setLayout(new GridLayout(4,1,10,5));
Ftemp.add(new JLabel("Input Scale"));
Ftemp.add(incel = new JRadioButton("Celcius",true));
Ftemp.add(infah = new JRadioButton("Fahrenheit"));
Ftemp.add(inkel = new JRadioButton("Kelvin"));
ButtonGroup fTemp = new ButtonGroup();
fTemp.add(incel);
fTemp.add(infah);
fTemp.add(inkel);
JPanel Ttemp = new JPanel();
Ttemp.setLayout(new GridLayout(4,1,10,5));
Ttemp.add(new JLabel("Output Scale"));
Ttemp.add(outcel = new JRadioButton("Celcius"));
Ttemp.add(outfah = new JRadioButton("Fahrenheit", true));
Ttemp.add(outkel = new JRadioButton("Kelvin"));
ButtonGroup tTemp = new ButtonGroup();
tTemp.add(outcel);
tTemp.add(outfah);
tTemp.add(outkel);
add(input, BorderLayout.NORTH);
add(output, BorderLayout.SOUTH);
add(Ftemp, BorderLayout.WEST);
add(Ttemp, BorderLayout.EAST);
setSize(300, 200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tempInput.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent E)
{
}});
class inCalc extends JPanel
{
private double = 0;
public double calculate()
{
intext = tempInput.getText();
intemp = (double parse.Double(intext));
if (incel)
{
if (outfah)
{
outtemp = ((intemp * (9 / 5)) + 32);
tempOutput.setMessage(outtemp);
}
}
}
}
}