Are you saying that you have NOT changed the code since the first post on March 16?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class TempConverter extends JFrame implements ActionListener
{
int inScale=0,outScale=0;//stores scale of input and output temperature
String p="";//To store action command
ButtonGroup inputGroup,outputGroup;
JRadioButton b1_panel1,b2_panel1,b3_panel1;//radio buttons for selecting input temperature
JRadioButton b1_panel2,b2_panel2,b3_panel2;//radio buttons for selecting output temperatures
JButton b1_panel3,b2_panel3;//buttons for third panel
JTextField t1,t2;//for inputing and outputing statements
JPanel panel1,panel2,panel3;//panels for output and selcting scales
JLabel l1,l2;//to inform about input and output scales
public void frame()//to initialise frame
{
this.setSize(500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setPreferredSize(this.getPreferredSize());
this.setVisible(true);
}
public void panel1()//to initialise first panel
{
b1_panel1=new JRadioButton("Kelvin");
b2_panel1=new JRadioButton("Fahrenheit");
b3_panel1=new JRadioButton("Celsius");
inputGroup=new ButtonGroup();
inputGroup.add(b1_panel1);
inputGroup.add(b2_panel1);
inputGroup.add(b3_panel1);
l1=new JLabel("INPUT SCALE");
panel1=new JPanel();
panel1.setLayout(new BoxLayout(panel1,BoxLayout.LINE_AXIS));
panel1.add(l1);
panel1.add(b1_panel1);
panel1.add(b2_panel1);
panel1.add(b3_panel1);
panel1.setPreferredSize(panel1.getPreferredSize());
panel1.setVisible(true);
}
public void panel2()//to initialse second panel
{
b1_panel2=new JRadioButton("Kelvin");
b2_panel2=new JRadioButton("Fahrenheit");
b3_panel2=new JRadioButton("Celsius");
outputGroup=new ButtonGroup();
outputGroup.add(b1_panel2);
outputGroup.add(b2_panel2);
outputGroup.add(b3_panel2);
l2=new JLabel("OUTPUT SCALE");
panel2=new JPanel();
panel2.setLayout(new BoxLayout(panel2,BoxLayout.PAGE_AXIS));
panel2.add(l2);
panel2.add(b1_panel2);
panel2.add(b2_panel2);
panel2.add(b3_panel2);
panel2.setPreferredSize(panel2.getPreferredSize());
panel2.setVisible(true);
}
public void panel3()//to initialise third panel
{
b1_panel3=new JButton("CONVERT");
b2_panel3=new JButton("Back");
panel3=new JPanel();
panel3.setLayout(new BoxLayout(panel3,BoxLayout.PAGE_AXIS));
t1=new JTextField("Enter input temperature");
t2=new JTextField();
panel3.add(t1);
panel3.add(b1_panel3);
panel3.add(t2);
panel3.add(b2_panel3);
panel3.setPreferredSize(panel3.getPreferredSize());
panel3.setVisible(true);
}
public void start()//to add first panel to frame and set action commands
{
b1_panel1.addActionListener(this);
b1_panel1.setActionCommand("11");//first digit stores panel bieng used and second stores which button is pressed
b2_panel1.addActionListener(this);
b2_panel1.setActionCommand("12");
b3_panel1.addActionListener(this);
b3_panel1.setActionCommand("13");
b1_panel2.addActionListener(this);
b1_panel2.setActionCommand("21");
b2_panel2.addActionListener(this);
b2_panel2.setActionCommand("22");
b3_panel2.addActionListener(this);
b3_panel2.setActionCommand("23");
b1_panel3.addActionListener(this);
b1_panel3.setActionCommand("31");
b2_panel3.addActionListener(this);
b2_panel3.setActionCommand("32");
this.add(panel1);
}
public void actionPerformed(ActionEvent e)
{
p=e.getActionCommand();
switch(p.charAt(0))
{
case '1'://first panel is used
this.removeAll();
this.add(panel2);
inScale=Integer.valueOf(p.charAt(1));//setting input scale
break;
case '2'://second panel is used
this.removeAll();
this.add(panel3);
outScale=Integer.valueOf(p.charAt(1));//setting output scale
break;
case '3'://last panel is used
switch(p.charAt(1))
{
case '1'://used pressed back button
this.removeAll();
this.add(panel1);
break;
case '2'://user pressed convert button
Double i=Double.parseDouble(t1.getText());
Double r=calculate(i);//converting temperture
t2.setText(Double.toString(r));break;
}
}
}
public Double calculate(Double i)//to calculate output temperature
{
Double r=0.0;
switch(this.inScale)
{
case 1://input scale=kelvin
switch(this.outScale)
{
case 1://output scale=kelvin
r=i;break;
case 2://output scale=farenhiet
r=9/5*(i-273.15)+32;break;
case 3://output scale=celcius
r=i-273.15;break;
}
break;
case 2://input scale=farenhiet
switch(this.outScale)
{
case 1://output scale=kelvin
r=(5/9*(i-32)+273.15);;break;
case 2://output scale=farenhiet
r=i;break;
case 3://output scale=celcieus
r=5/9*(i-32);break;
}
break;
case 3://input scale=celcius
switch(this.outScale)
{
case 1://output scale=kelvin
r=i+273.15;break;
case 2://output scale=farenhiet
r=(9/5*i)+32;break;
case 3://output scale=celcieus
r=i;break;
}
break;
}
return(r);
}
}
class test
{
public static void main(String args[])throws IOException
{
TempConverter q=new TempConverter();
q.setTitle("Temperature Converter");
q.panel1();
q.panel2();
q.panel3();
q.start();
}
}
The above code has a compiler error that needs to be fixed.
You need to read the tutorial on how to build a Swing GUI:
http://docs.oracle.com/javase/tutori...ing/index.html