private JPanel createBattlefieldSlidersPanel() {
    JPanel panel = new JPanel();

    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);

    GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup();

    GroupLayout.ParallelGroup left = layout.createParallelGroup();
    left.addComponent(battlefieldSizeLabel);
    left.addComponent(battlefieldWidthSlider);
    leftToRight.addGroup(left);

    GroupLayout.ParallelGroup right = layout.createParallelGroup();
    right.addComponent(battlefieldHeightSlider);
    leftToRight.addGroup(right);

    GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup();

    GroupLayout.ParallelGroup top = layout.createParallelGroup();
    top.addComponent(battlefieldSizeLabel);
    top.addComponent(battlefieldHeightSlider);
    topToBottom.addGroup(top);

    GroupLayout.ParallelGroup bottom = layout.createParallelGroup();
    bottom.addComponent(battlefieldWidthSlider);
    topToBottom.addGroup(bottom);

    layout.setHorizontalGroup(leftToRight);
    layout.setVerticalGroup(topToBottom);

    return panel;
  }
Пример #2
0
  /**
   * Universally creates layout for dialog.
   *
   * @param jcs
   */
  protected final void createLayout(JComponent... jcs) {
    Container pane = getContentPane();
    GroupLayout gl = new GroupLayout(pane);
    pane.setLayout(gl);

    gl.setAutoCreateContainerGaps(true);
    gl.setAutoCreateGaps(true);

    GroupLayout.ParallelGroup pg = gl.createParallelGroup(CENTER);

    for (JComponent jc : jcs) {
      pg.addComponent(jc).addGap(200);
    }
    gl.setHorizontalGroup(pg);

    GroupLayout.SequentialGroup sg = gl.createSequentialGroup();

    for (JComponent jc : jcs) {
      sg.addGap(30).addComponent(jc).addGap(20);
    }
    gl.setVerticalGroup(sg);

    pack();
  }
Пример #3
0
  public void createGUI() {

    JButton submitButton = new JButton("Submit");
    submitButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            // get text from input fields
            inputPath = inputField.getText();
            outputPath = outputField.getText();

            buttonPressed = true;
          }
        });

    JPanel inputPanel = new JPanel();
    inputPanel.add(new JLabel("Input Path"));
    inputPanel.add(inputField);

    JLabel inputLabel = new JLabel("Input Path");
    JLabel outputLabel = new JLabel("Output Path");

    JPanel content = new JPanel();
    content.setLayout(new BorderLayout());

    JPanel textFieldsContent = new JPanel();
    GroupLayout layout = new GroupLayout(textFieldsContent);
    textFieldsContent.setLayout(layout);

    // setting to true creates gaps between components
    layout.setAutoCreateGaps(true);
    // setting to true creates gaps between components and edge of container
    layout.setAutoCreateContainerGaps(true);

    // horizontal axis
    GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup();
    // each sequential group contains two parallel groups.
    //  one will contain labels, other will contain text fields
    horizontalGroup.addGroup(
        layout.createParallelGroup().addComponent(inputLabel).addComponent(outputLabel));
    horizontalGroup.addGroup(
        layout.createParallelGroup().addComponent(inputField).addComponent(outputField));
    layout.setHorizontalGroup(horizontalGroup);

    // vertical axis
    GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
    verticalGroup.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(inputLabel)
            .addComponent(inputField));
    verticalGroup.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(outputLabel)
            .addComponent(outputField));
    layout.setVerticalGroup(verticalGroup);

    content.add(textFieldsContent, BorderLayout.CENTER);
    content.add(submitButton, BorderLayout.PAGE_END);

    window.setContentPane(content);
    window.setSize(350, 200);
    window.setLocation(100, 100);
    window.setVisible(true);
  }
  @Override
  public JComponent createOptionsPanel() {
    final JPanel panel = new JPanel();
    final JLabel textFieldLabel = new JLabel(getConfigurationLabel());
    final JFormattedTextField valueField = prepareNumberEditor("m_limit");
    final JLabel comboBoxLabel =
        new JLabel(InspectionGadgetsBundle.message("constructor.visibility.option"));
    final JComboBox comboBox = new JComboBox();
    comboBox.addItem(Scope.NONE);
    comboBox.addItem(Scope.PRIVATE);
    comboBox.addItem(Scope.PACKAGE_LOCAL);
    comboBox.addItem(Scope.PROTECTED);
    comboBox.setRenderer(
        new ListCellRendererWrapper() {
          @Override
          public void customize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof Scope) setText(((Scope) value).getText());
          }
        });
    comboBox.setSelectedItem(ignoreScope);
    comboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ignoreScope = (Scope) comboBox.getSelectedItem();
          }
        });
    comboBox.setPrototypeDisplayValue(Scope.PROTECTED);

    final GroupLayout layout = new GroupLayout(panel);
    layout.setAutoCreateGaps(true);
    panel.setLayout(layout);
    final GroupLayout.ParallelGroup horizontal = layout.createParallelGroup();
    horizontal.addGroup(
        layout
            .createSequentialGroup()
            .addComponent(textFieldLabel)
            .addComponent(
                valueField,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));
    horizontal.addGroup(
        layout
            .createSequentialGroup()
            .addComponent(comboBoxLabel)
            .addComponent(comboBox, 100, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
    layout.setHorizontalGroup(horizontal);
    final GroupLayout.SequentialGroup vertical = layout.createSequentialGroup();
    vertical.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(textFieldLabel)
            .addComponent(valueField));
    vertical.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(comboBoxLabel)
            .addComponent(comboBox));
    layout.setVerticalGroup(vertical);

    return panel;
  }
  private JPanel createRulesPanel() {
    JPanel panel = new JPanel();

    panel.addAncestorListener(new EventHandler());
    panel.setBorder(BorderFactory.createEtchedBorder());

    GroupLayout layout = new GroupLayout(panel);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    panel.setLayout(layout);

    GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup();

    GroupLayout.ParallelGroup left = layout.createParallelGroup();
    left.addComponent(numberOfRoundsLabel);
    left.addComponent(gunCoolingRateLabel);
    left.addComponent(inactivityTimeLabel);
    left.addComponent(sentryBorderSizeLabel);
    left.addComponent(hideEnemyNamesLabel);
    leftToRight.addGroup(left);

    GroupLayout.ParallelGroup right = layout.createParallelGroup();
    right.addComponent(getNumberOfRoundsTextField());
    right.addComponent(getGunCoolingRateTextField());
    right.addComponent(getInactivityTimeTextField());
    right.addComponent(getSentryBorderSizeTextField());
    right.addComponent(hideEnemyNamesCheckBox);
    leftToRight.addGroup(right);

    GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup();

    GroupLayout.ParallelGroup row0 = layout.createParallelGroup(Alignment.BASELINE);
    row0.addComponent(numberOfRoundsLabel);
    row0.addComponent(numberOfRoundsTextField);
    topToBottom.addGroup(row0);

    GroupLayout.ParallelGroup row1 = layout.createParallelGroup(Alignment.BASELINE);
    row1.addComponent(gunCoolingRateLabel);
    row1.addComponent(getGunCoolingRateTextField());
    topToBottom.addGroup(row1);

    GroupLayout.ParallelGroup row2 = layout.createParallelGroup(Alignment.BASELINE);
    row2.addComponent(inactivityTimeLabel);
    row2.addComponent(inactivityTimeTextField);
    topToBottom.addGroup(row2);

    GroupLayout.ParallelGroup row3 = layout.createParallelGroup(Alignment.BASELINE);
    row3.addComponent(sentryBorderSizeLabel);
    row3.addComponent(sentryBorderSizeTextField);
    topToBottom.addGroup(row3);

    GroupLayout.ParallelGroup row4 = layout.createParallelGroup(Alignment.CENTER);
    row4.addComponent(hideEnemyNamesLabel);
    row4.addComponent(hideEnemyNamesCheckBox);
    topToBottom.addGroup(row4);

    layout.setHorizontalGroup(leftToRight);
    layout.setVerticalGroup(topToBottom);

    return panel;
  }