title: Controlling components on in JFrame
body: <p>I am struggling controlling my components. I hava a JFrame which contains a JPanel. My components such as JLabel and JTextArea are added to this Panel. So my question is:</p>
  
  <p>How can I control these compontens? I've tried using</p>
  
  <p><code>GridBagConstraints constraints = new GridBagConstraints();
   constraints.gridx = 1;</code></p>
  
  <p>But it doesn't seems to work..</p>
  
  <p>Here is my function the initialize my GUI:</p>
  
  <pre><code>public void initGUI()
  {
  
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();  
  
      final JFrame frame = new JFrame("instantINFO!");
                   frame.setSize(screenSize.width, screenSize.height); 
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setLayout(new GridBagLayout()); 
  
      final JPanel panel = new JPanel();
  
      weather = new JTextArea(vær, 6, 20);
      weather.setFont(new Font("Arial", Font.BOLD, 16));
      weather.setLineWrap(true);
      weather.setWrapStyleWord(true);
      weather.setOpaque(false);
      weather.setEditable(false);
  
      stedLabel = new JLabel(sted);
      dagLabel = new JLabel(dag);
  
      panel.add(weather);
      panel.add(stedLabel); 
      panel.add(dagLabel); 
  
      frame.add(panel);
      frame.setVisible(true);
  
  }
  </code></pre>
  
  <p>For instance I want the weather label to be in the left upper corner, with a few pixels of margin. </p>