private void applyLayout() {
    GroupLayout gl = new GroupLayout(getContentPane());
    gl.setAutoCreateContainerGaps(true);
    gl.setAutoCreateGaps(true);
    setLayout(gl);

    JLabel lFind = new JLabel(Runner.editorInterface.getString("FindDialog.FIND_LABEL")); //$NON-NLS-1$
    tFind = new JComboBox<String>();
    tFind.setEditable(true);
    tFind.getEditor().addActionListener(new EnterListener());

    JLabel lReplace = new JLabel(Runner.editorInterface.getString("FindDialog.REPLACE_LABEL")); //$NON-NLS-1$
    tReplace = new JComboBox<String>();
    tReplace.setEditable(true);
    tReplace.getEditor().addActionListener(new EnterListener());

    JPanel options = new JPanel();
    options.setLayout(new BoxLayout(options, BoxLayout.PAGE_AXIS));
    options.setBorder(BorderFactory.createTitledBorder(Runner.editorInterface.getString("FindDialog.OPTIONS"))); //$NON-NLS-1$
    options.add(whole = new JCheckBox(Runner.editorInterface.getString("FindDialog.WHOLE_WORD"))); //$NON-NLS-1$
    options.add(start = new JCheckBox(Runner.editorInterface.getString("FindDialog.WORD_START"))); //$NON-NLS-1$
    options.add(wrap = new JCheckBox(Runner.editorInterface.getString("FindDialog.WRAP_EOF"))); //$NON-NLS-1$
    wrap.setSelected(true);
    options.add(sens = new JCheckBox(Runner.editorInterface.getString("FindDialog.CASE_SENSITIVE"))); //$NON-NLS-1$
    options.add(esc = new JCheckBox(Runner.editorInterface.getString("FindDialog.ESCAPE_SEQS"))); //$NON-NLS-1$
    options.add(regex = new JCheckBox(Runner.editorInterface.getString("FindDialog.REGEX"))); //$NON-NLS-1$
    options.add(backward = new JCheckBox(Runner.editorInterface.getString("FindDialog.BACKWARDS"))); //$NON-NLS-1$

    new ButGroup(whole, start);
    new ButGroup(esc, regex);
    regex.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent e) {
        boolean b = regex.isSelected();
        backward.setEnabled(!b);
      }
    });

    JPanel scope = new JPanel();
    scope.setLayout(new BoxLayout(scope, BoxLayout.PAGE_AXIS));
    scope.setBorder(BorderFactory.createTitledBorder(Runner.editorInterface.getString("FindDialog.SCOPE"))); //$NON-NLS-1$

    ButtonGroup bg = new ButtonGroup();

    // TODO: Modularize to avoid ties to LGM.
    bg.add(scGame = new JRadioButton(Runner.editorInterface.getString("FindDialog.GAME"))); //$NON-NLS-1$
    scope.add(scGame);
    bg.add(scObject = new JRadioButton(Runner.editorInterface.getString("FindDialog.OBJECT"))); //$NON-NLS-1$
    scope.add(scObject);
    bg.add(scEvent = new JRadioButton(Runner.editorInterface.getString("FindDialog.EVENT"))); //$NON-NLS-1$
    scope.add(scEvent);
    bg.add(scCode = new JRadioButton(Runner.editorInterface.getString("FindDialog.CODE"), true)); //$NON-NLS-1$
    scope.add(scCode);
    bg.add(scSel = new JRadioButton(Runner.editorInterface.getString("FindDialog.SELECTION"))); //$NON-NLS-1$
    scope.add(scSel);

    bFind = new JButton(Runner.editorInterface.getString("FindDialog.FIND")); //$NON-NLS-1$
    bFind.addActionListener(this);
    bReplace = new JButton(Runner.editorInterface.getString("FindDialog.REPLACE")); //$NON-NLS-1$
    bReplace.addActionListener(this);
    bRepAll = new JButton(Runner.editorInterface.getString("FindDialog.REPLACE_ALL")); //$NON-NLS-1$
    bRepAll.addActionListener(this);
    JButton bClose = new JButton(Runner.editorInterface.getString("FindDialog.CLOSE")); //$NON-NLS-1$

    bFind.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (selectedJoshText == null) {
          System.err.println("No text editor selected. Ever."); //$NON-NLS-1$
          return;
        }
        setVisible(false);
        selectedJoshText.finder.updateParameters((String) tFind.getEditor().getItem(),
            (String) tReplace.getEditor().getItem());
        selectedJoshText.finder.present();
        if (backward.isSelected()) {
          selectedJoshText.finder.findPrevious();
        } else {
          selectedJoshText.finder.findNext();
        }
      }
    });
    bReplace.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (selectedJoshText == null) {
          System.err.println("No text editor selected. Ever."); //$NON-NLS-1$
          return;
        }
        setVisible(false);
        selectedJoshText.finder.updateParameters((String) tFind.getEditor().getItem(),
            (String) tReplace.getEditor().getItem());
        selectedJoshText.finder.present();
        if (backward.isSelected()) {
          selectedJoshText.finder.replacePrevious();
        } else {
          selectedJoshText.finder.replaceNext();
        }
      }
    });

    bRepAll.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (selectedJoshText == null) {
          System.err.println("No text editor selected. Ever."); //$NON-NLS-1$
          return;
        }
        setVisible(false);
        selectedJoshText.finder.updateParameters((String) tFind.getEditor().getItem(),
            (String) tReplace.getEditor().getItem());
        int results = selectedJoshText.finder.replaceAll();
        JOptionPane.showMessageDialog(null,
            String.format(Runner.editorInterface.getString("FindDialog.OCCURRENCES_REPL"), //$NON-NLS-1$
                results));
      }
    });

    bClose.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        dispose();
      }
    });

    int pref = GroupLayout.PREFERRED_SIZE;

    gl.setHorizontalGroup(gl.createParallelGroup()
    /**/.addGroup(gl.createSequentialGroup()
    /*	*/.addGroup(gl.createParallelGroup()
    /*		*/.addComponent(lFind)
    /*		*/.addComponent(lReplace))
    /*	*/.addGroup(gl.createParallelGroup()
    /*		*/.addComponent(tFind)
    /*		*/.addComponent(tReplace)))
    /**/.addGroup(gl.createSequentialGroup()
    /*	*/.addComponent(options, pref, pref, Integer.MAX_VALUE)
    /*	*/.addComponent(scope, pref, pref, Integer.MAX_VALUE))
    /**/.addGroup(gl.createSequentialGroup()
    /*	*/.addComponent(bFind, pref, pref, Integer.MAX_VALUE)
    /*	*/.addComponent(bReplace, pref, pref, Integer.MAX_VALUE)
    /*	*/.addComponent(bRepAll, pref, pref, Integer.MAX_VALUE)
    /*	*/.addComponent(bClose, pref, pref, Integer.MAX_VALUE)));

    gl.setVerticalGroup(gl.createSequentialGroup()
    /**/.addGroup(gl.createParallelGroup()
    /*	*/.addComponent(lFind)
    /*	*/.addComponent(tFind, pref, pref, pref))
    /**/.addGroup(gl.createParallelGroup()
    /*	*/.addComponent(lReplace)
    /*	*/.addComponent(tReplace, pref, pref, pref))
    /**/.addGroup(gl.createParallelGroup()
    /*	*/.addComponent(options, pref, pref, Integer.MAX_VALUE)
    /*	*/.addComponent(scope, pref, pref, Integer.MAX_VALUE))
    /**/.addGroup(gl.createParallelGroup()
    /*	*/.addComponent(bFind)
    /*	*/.addComponent(bReplace)
    /*	*/.addComponent(bRepAll)
    /*	*/.addComponent(bClose)));
  }