I write Swing code to display three text fields and labels and one button, but the button displays at top the frame. I want to move it to the bottom of the three text fields. Here is my code:
import javax.swing.*;
import java.awt.*;
class textfield 
{
    public static void main(String[] args) 
    {
        JFrame jf;
        JLabel rcno,name,amount;
        JTextField rc_no,na_me,am_t;
        JButton ok;
        JPanel p1,p2;
        jf=new JFrame("Billing");
        rcno=new JLabel("Recipt No:   ");
        rc_no=new JTextField(6);
        name=new JLabel("Student Name:   ");
        na_me=new JTextField(20);
        amount=new JLabel("Amount:   ");
        am_t=new JTextField(5);
        ok=new JButton("ok");
        p1=new JPanel();
        //p1.setLayout(new FlowLayout());
        p1.setLayout(new GridLayout(3,2,5,5));
        p1.add(rcno);
        p1.add(rc_no);
        p1.add(name);
        p1.add(na_me);
        p1.add(amount);
        p1.add(am_t);
        p2=new JPanel();
        p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
        //ok.setPreferredSize(new Dimension(50,20));
        p2.add(ok);
        p1.setBounds(110,100,200,100);
        //p2.setBounds(220,220,10,10);
        jf.add(p1);
        jf.add(p2);
        jf.setSize(400,500);
        jf.setVisible(true);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
 
    
 
    