Here is my code for creating a frame with a text field:
   static  void showteacherDel()
    {
    JFrame frame3 = new JFrame();
    frame3.setSize(640,480);
    JPanel pn = new JPanel();
    pn.setSize(640,480);
    frame3.add(pn);
    frame3.setResizable(false);
    JTextField tf = new JTextField();
    tf.setSize(300,500);
    Component add = pn.add(tf);
    //frame3.pack();
    frame3.setVisible(true);
 }
}
Now here is the problem. You see that I have created a panel and then added my text field to it.
The reason for that was that my text field, no matter what size I set, spawned whole of the frame.
So I created a panel and added the text field to it.
But no matter what size I give, it shows a point object, which is actually a text field.
 
     
     
     
    