title: How does intelliJ process and compile Swing app code?
body: <p>I tried building simple Swing forms using IntelliJ's GUI designer tool and noticed some things I don't like (at least till I don't understand). For this question lets consider a very simple Swing form with just one button. I opened up GUI designer and added a button( 'load file') to the middle of mainPanel using GridBagLayout. The java code it generated (I wrote the main method myself):</p>
  
  <pre><code>package mainPackage;
  
  import javax.swing.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  /**
   * Created by Povilas on 06/01/2017.
   */
  public class MainFrame {
    private JButton loadFileButton;
    private JPanel mainPanel;
  
    public MainFrame() {   
  
      loadFileButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          JOptionPane.showMessageDialog(null,"This should be a browser dialog...");
        }
      });
  
    }
  
    public static void main(String[] args) {
      MainFrame mainFrame = new MainFrame();
      JFrame frame = new JFrame("App");
      frame.setContentPane(mainFrame.mainPanel);    
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
      frame.pack();    
      frame.setVisible(true);
    }
  }
  </code></pre>
  
  <p>If i run this code it works, which is crazy and unexpected, because nowhere in the code loadFileButton is initialized, nowhere in the code mainPanel is initialized, nowhere in thecode is LayoutManager added or button added to the panel. If i tried compiling this code from cmd I would get NullPointer exceptions in the constructor because button and panel are not initalized.</p>
  
  <p>Question:
  How come intelliJ compiles and runs the app successfully? Does it process .form file at compile time to add missing code? I want to design Swing dialogs with IntelliJ's designer but to get proper, full code which could then be compiled and packaged a from cmd using javac and jar, how do I do that?</p>