class TempConverter extends JFrame implements ActionListener
{
   int inScale=0,outScale=0;//stores scale of input and output temperature
   double r=0.0;
   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;//for inputing and outputing statements
   JPanel panel1,panel2,panel3;//panels for output and selcting scales
   JLabel l1,l2,l3;//to inform about input and output scales
   public void frame()//to initialise frame and invokes panel1
   public void panel1()//to initialise first panel and invokes panel2
   {
      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);
      this.panel2();
   }
   public void panel2()//to initialse second panel  and invokes panel3
   public void panel3()//to initialise third panel  and invokes start method
   {   
      panel3=new JPanel();
      panel3.setLayout(new BoxLayout(panel3,BoxLayout.PAGE_AXIS));
      t1=new JTextField("Enter input temperature-");
      l3=new JLabel();
      panel3.add(t1);
      panel3.add(b1_panel3);
      panel3.add(l3);
      panel3.add(b2_panel3);
      panel3.setPreferredSize(panel3.getPreferredSize());
      panel3.setVisible(true);
      this.start();
   }
   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);
      this.validate();
   }
   public void actionPerformed(ActionEvent e)
   {
       p=e.getActionCommand();
       switch(p.charAt(0))
       {    
           case '1'://first panel is used
           this.remove(panel1);
           this.add(panel2);
           inScale=Integer.valueOf(p.charAt(1));//setting input scale
           break;
           case '2'://second panel is used
           this.remove(panel2);
           this.add(panel3);
           outScale=Integer.valueOf(p.charAt(1));//setting output scale
           break;
           case '3'://last panel is used
           switch(p.charAt(1))
           {
                case '2'://used pressed back button
                this.remove(panel3);
                this.add(panel1);
                break;
                case '1'://user pressed convert button
                Double i=Double.parseDouble(t1.getText().substring(23));
                Double r=calculate(i);//converting temperture
                l3.setText(Double.toString(r));function.sopln(p);
           }   
       }
       this.validate();
   }
   public Double calculate(Double i)//to calculate output temperature
   {
           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;
                }
           }
           return(r);   
   }
}
the program works mostly fine.selecting scale and adding input temperature is done but calculation is done the program does not enter the switch block in the calculate method it just displays the initial value if r.also when the return button is pressed the buttons of panel1 are displayed after a moment but the rest of the panel stays the same.the validate function necessary and what does it do actually.