title: Java change JTextField size inside a GridLayout
body: <p>I have a GridLayout(3,2) as follows with 2 JLabels, 2 JTextFields and a JButton. I add them as shown in the pic or code. Everything is just fine but the JTextField size is too big and I want it to be as shown by the red lines I've drawed. I have tried saying <code>jtf3.setPreferredSize( new Dimension( x, y ) );</code> but it didn't change the dimension at all. One other solution was to make the GridLayout somewhat <code>GridLayout(3,2,1,50)</code> for example (by adding 50) but that moves the JLabels way top too... I just want to be exactly as shown in the pic... Any ideas? Thanks a lot</p>
  
  <p><img src="https://i.stack.imgur.com/nK1OO.jpg" alt="enter image description here"></p>
  
  <pre><code>JPanel copying_panel = new JPanel();
  copying_panel.setLayout(new GridLayout(3, 2));
  copying_panel.setBackground(new Color(200, 221, 242));
  JLabel jl4 = new JLabel("From:", SwingConstants.CENTER);
  JTextField jtf3 = new JTextField();
  JLabel jl5 = new JLabel("To:", SwingConstants.CENTER);
  JTextField jtf4 = new JTextField();
  JLabel jl6 = new JLabel();
  JButton jb2 = new JButton("Go");
  
  copying_panel.add(jl4);
  copying_panel.add(jtf3);
  copying_panel.add(jl5);
  copying_panel.add(jtf4);
  copying_panel.add(jl6);
  copying_panel.add(jb2);
  </code></pre>