Java Code Examples for javax.swing.GroupLayout#setAutoCreateContainerGaps()

The following examples show how to use javax.swing.GroupLayout#setAutoCreateContainerGaps() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StockpileDialog.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private void updatePanels() {
	jFiltersPanel.removeAll();
	GroupLayout groupLayout = new GroupLayout(jFiltersPanel);
	jFiltersPanel.setLayout(groupLayout);
	groupLayout.setAutoCreateGaps(true);
	groupLayout.setAutoCreateContainerGaps(false);
	ParallelGroup horizontalGroup = groupLayout.createParallelGroup();
	SequentialGroup verticalGroup = groupLayout.createSequentialGroup();
	for (LocationPanel locationPanel : locationPanels) {
		horizontalGroup.addComponent(locationPanel.getPanel());
		verticalGroup.addComponent(locationPanel.getPanel());
	}
	jFiltersPanel.setVisible(!locationPanels.isEmpty());
	groupLayout.setHorizontalGroup(horizontalGroup);
	groupLayout.setVerticalGroup(verticalGroup);
	autoValidate();
	this.getDialog().pack();
}
 
Example 2
Source File: BackgroundProgress.java    From open-ig with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Build the dialog. */
public BackgroundProgress() {
	setTitle("Work in background");
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	setModal(true);
	
	label = new JLabel("Working...");
	progress = new JProgressBar();
	progress.setIndeterminate(true);
	
	Container c = getContentPane();
	GroupLayout gl = new GroupLayout(c);
	c.setLayout(gl);
	gl.setAutoCreateContainerGaps(true);
	gl.setAutoCreateGaps(true);
	
	gl.setHorizontalGroup(gl.createParallelGroup(Alignment.CENTER)
			.addComponent(label).addComponent(progress));
	gl.setVerticalGroup(gl.createSequentialGroup().addComponent(label).addComponent(progress));
	
	pack();
	setResizable(false);
}
 
Example 3
Source File: JSettingsPanel.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JSettingsPanel(final Program program, final SettingsDialog settingsDialog, final String title, final Icon icon) {
	this.program = program;
	this.title = title;
	this.parent = settingsDialog.getDialog();
	this.icon = icon;

	jPanel = new JPanel();

	layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);
}
 
Example 4
Source File: OtherSettingsDialog.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create the graphics panel.
 * @param font the font
 * @return the panel
 */
JPanel createGraphicsPanel(Font font) {
	JPanel p = new JPanel();
	TitledBorder tb = BorderFactory.createTitledBorder(labels.get("othersettings.graphics_troubleshoot"));
	tb.setTitleFont(font);
	p.setBorder(tb);

	disableD3D = new IGCheckBox(labels.get("othersettings.disable_d3d"), font);
	disableDDraw = new IGCheckBox(labels.get("othersettings.disable_ddraw"), font);
	disableOpenGL = new IGCheckBox(labels.get("othersettings.disable_opengl"), font);
	JLabel restartProgram = new JLabel(labels.get("othersettings.restart_program"));
	restartProgram.setFont(font);

	GroupLayout gl = new GroupLayout(p);
	p.setLayout(gl);
	gl.setAutoCreateContainerGaps(true);
	gl.setAutoCreateGaps(true);
	
	gl.setHorizontalGroup(
		gl.createParallelGroup()
		.addComponent(disableD3D)
		.addComponent(disableDDraw)
		.addComponent(disableOpenGL)
		.addComponent(restartProgram)
	);
	gl.setVerticalGroup(
		gl.createSequentialGroup()
		.addComponent(disableD3D)
		.addComponent(disableDDraw)
		.addComponent(disableOpenGL)
		.addComponent(restartProgram)
	);
	
	return p;
}
 
Example 5
Source File: AddEncodeDecodeOutputPanelDialog.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

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

    JLabel nameLabel = new JLabel(NAME_FIELD_LABEL);
    JLabel scriptsLabel = new JLabel(SCRIPTS_FIELD_LABEL);

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                    .addComponent(nameLabel)
                                    .addComponent(scriptsLabel))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addComponent(getNameTextField())
                                    .addComponent(getProcessorComboboxField())));

    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(nameLabel)
                                    .addComponent(getNameTextField()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(scriptsLabel)
                                    .addComponent(getProcessorComboboxField())));

    return fieldsPanel;
}
 
Example 6
Source File: JLockWindow.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JLockWindow(final Window parent) {
	this.parent = parent;
	jWindow = new JWindow(parent);

	jProgress = new JProgressBar(0, 100);

	JPanel jPanel = new JPanel();
	jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
	GroupLayout layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);
	jWindow.add(jPanel);

	jLabel = new JLabel();


	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.CENTER)
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
}
 
Example 7
Source File: StockpileDialog.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public BorderPanel(String title, Alignment alignment) {
	this.alignment = alignment;
	jPanel = new JPanel();
	layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(false);
	jPanel.setBorder(BorderFactory.createTitledBorder(title));
}
 
Example 8
Source File: AddEncodeDecodeTabDialog.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

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

    JLabel nameLabel = new JLabel(NAME_FIELD_LABEL);

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                    .addComponent(nameLabel))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addComponent(getNameTextField())));

    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(nameLabel)
                                    .addComponent(getNameTextField())));

    return fieldsPanel;
}
 
Example 9
Source File: JColorTable.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public MyComboBox() {

			jPanel = new JPanel();

			GroupLayout layout = new GroupLayout(jPanel);
			jPanel.setLayout(layout);
			layout.setAutoCreateGaps(false);
			layout.setAutoCreateContainerGaps(false);

			jDefault = new JNullableLabel();
			jDefault.setHorizontalAlignment(JLabel.CENTER);
			jDefault.setVerticalAlignment(JLabel.CENTER);
			jDefault.setOpaque(true);

			jPickerIcon = new JLabel(Images.SETTINGS_COLOR_PICKER.getIcon());
			jPickerIcon.setHorizontalTextPosition(JLabel.CENTER);
			jPickerIcon.setHorizontalAlignment(JLabel.CENTER);
			jPickerIcon.setVerticalAlignment(JLabel.CENTER);
			jPickerIcon.setOpaque(true);

			layout.setHorizontalGroup(
			layout.createSequentialGroup()
					.addComponent(jDefault, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
					.addComponent(jPickerIcon, 16, 16, 16)
			);
			layout.setVerticalGroup(
				layout.createParallelGroup(GroupLayout.Alignment.LEADING)
					.addComponent(jDefault, 0, 0, Integer.MAX_VALUE)
					.addComponent(jPickerIcon, 0, 0, Integer.MAX_VALUE)
			);
		}
 
Example 10
Source File: JythonOptionsPanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
    super.setName(Constant.messages.getString("jython.options.title"));

    JLabel modulesPathLabel =
            new JLabel(Constant.messages.getString("jython.options.label.modulepath"));
    this.modulesPathTextField = new JTextField();
    this.pathChooseButton =
            new JButton(Constant.messages.getString("jython.options.label.choose"));

    GroupLayout layout = new GroupLayout(this);
    super.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(
                            layout.createSequentialGroup()
                                    .addComponent(modulesPathLabel)
                                    .addComponent(this.modulesPathTextField)
                                    .addComponent(this.pathChooseButton)));
    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(modulesPathLabel)
                                    .addComponent(this.modulesPathTextField)
                                    .addComponent(this.pathChooseButton)));

    this.pathChooseButton.addActionListener(
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JFileChooser chooser =
                            new JFileChooser(
                                    JythonOptionsPanel.this.modulesPathTextField.getText());
                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                    chooser.setAcceptAllFileFilterUsed(false);
                    if (JFileChooser.APPROVE_OPTION
                            == chooser.showOpenDialog(JythonOptionsPanel.this)) {
                        JythonOptionsPanel.this.modulesPathTextField.setText(
                                chooser.getSelectedFile().getPath());
                    }
                }
            });
}
 
Example 11
Source File: OptionsDialog.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates a JPanel with the specified options. Interal use only.
 * 
 * @param opts the options
 * @return a jpanel
 */
private static JPanel optionsPanel(final List<Option> opts) {
	final JPanel options = new JPanel();
	final GroupLayout gl = new GroupLayout(options);

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

	final GroupLayout.ParallelGroup labels = gl.createParallelGroup();
	final GroupLayout.ParallelGroup values = gl.createParallelGroup();
	final GroupLayout.ParallelGroup titles = gl.createParallelGroup();
	final GroupLayout.ParallelGroup horiz = gl.createParallelGroup();
	final GroupLayout.SequentialGroup cols = gl.createSequentialGroup();
	final GroupLayout.SequentialGroup rows = gl.createSequentialGroup();

	cols.addGroup(labels);
	cols.addGroup(values);
	horiz.addGroup(cols);
	horiz.addGroup(titles);

	for (final Option o : opts) {
		final JLabel l = o.getLabel();
		final JComponent c = o.getComponent();

		if (c == null) {
			// This is a label-only row, allowed to take up the whole row
			titles.addComponent(l);
			rows.addComponent(l);
		} else {
			if (l.getBorder() == null) {
				l.setBorder(new EmptyBorder(3, 0, 0, 0));
			}

			if (l.getLabelFor() == null) {
				l.setLabelFor(c);
			}

			labels.addComponent(l);
			values.addComponent(c);

			final GroupLayout.ParallelGroup row = gl.createParallelGroup(GroupLayout.Alignment.BASELINE);

			row.addComponent(l);
			row.addComponent(c);
			rows.addGroup(row);
		}
	}

	gl.setHorizontalGroup(horiz);
	gl.setVerticalGroup(rows);

	return options;
}
 
Example 12
Source File: DialogAddApp.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

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

    JLabel displayNameLabel = new JLabel(DISPLAY_NAME_FIELD_LABEL);
    JLabel fullCommandLabel = new JLabel(FULL_COMMAND_FIELD_LABEL);
    JLabel workingDirLabel = new JLabel(WORKING_DIR_FIELD_LABEL);
    JLabel parametersLabel = new JLabel(PARAMETERS_FIELD_LABEL);
    JLabel captureOutputLabel = new JLabel(CAPTURE_OUTPUT_FIELD_LABEL);
    JLabel outputToNoteLabel = new JLabel(OUTPUT_TO_NOTE_FIELD_LABEL);
    JLabel enabledLabel = new JLabel(ENABLED_FIELD_LABEL);

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                    .addComponent(displayNameLabel)
                                    .addComponent(fullCommandLabel)
                                    .addComponent(workingDirLabel)
                                    .addComponent(parametersLabel)
                                    .addComponent(captureOutputLabel)
                                    .addComponent(enabledLabel))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addComponent(getDisplayNameTextField())
                                    .addGroup(
                                            layout.createSequentialGroup()
                                                    .addComponent(getFullCommandTextField())
                                                    .addComponent(getChooseAppButton()))
                                    .addGroup(
                                            layout.createSequentialGroup()
                                                    .addComponent(getWorkingDirTextField())
                                                    .addComponent(getChooseDirButton()))
                                    .addComponent(getParametersTextField())
                                    .addGroup(
                                            layout.createSequentialGroup()
                                                    .addComponent(getCaptureOutputCheckBox())
                                                    .addComponent(outputToNoteLabel)
                                                    .addComponent(getOutputToNoteCheckBox()))
                                    .addComponent(getEnabledCheckBox())));

    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(displayNameLabel)
                                    .addComponent(getDisplayNameTextField()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(fullCommandLabel)
                                    .addComponent(getFullCommandTextField())
                                    .addComponent(getChooseAppButton()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(workingDirLabel)
                                    .addComponent(getWorkingDirTextField())
                                    .addComponent(getChooseDirButton()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(parametersLabel)
                                    .addComponent(getParametersTextField()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(captureOutputLabel)
                                    .addComponent(getCaptureOutputCheckBox())
                                    .addComponent(outputToNoteLabel)
                                    .addComponent(getOutputToNoteCheckBox()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(enabledLabel)
                                    .addComponent(getEnabledCheckBox())));

    return fieldsPanel;
}
 
Example 13
Source File: AddPayloadDialog.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout groupLayout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(groupLayout);
    groupLayout.setAutoCreateGaps(true);
    groupLayout.setAutoCreateContainerGaps(true);

    JLabel typeLabel = new JLabel(TYPE_FIELD_LABEL);

    groupLayout.setHorizontalGroup(
            groupLayout
                    .createParallelGroup()
                    .addGroup(
                            groupLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.TRAILING)
                                                    .addComponent(typeLabel))
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.LEADING)
                                                    .addComponent(
                                                            getPayloadUIHandlersComboBox())))
                    .addComponent(contentsPanel));

    groupLayout.setVerticalGroup(
            groupLayout
                    .createSequentialGroup()
                    .addGroup(
                            groupLayout
                                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(typeLabel)
                                    .addComponent(getPayloadUIHandlersComboBox()))
                    .addComponent(contentsPanel));

    return fieldsPanel;
}
 
Example 14
Source File: ExportDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
private JOptionPanel() {
	layout = new GroupLayout(this);
	this.setLayout(layout);
	layout.setAutoCreateGaps(false);
	layout.setAutoCreateContainerGaps(true);
}
 
Example 15
Source File: CEDefinitionPanel.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return the properties listing panel
 */
JPanel createPropertiesPanel() {
	JPanel p = new JPanel();
	
	GroupLayout gl = new GroupLayout(p);
	p.setLayout(gl);
	gl.setAutoCreateContainerGaps(true);
	gl.setAutoCreateGaps(true);
	
	SequentialGroup rows = gl.createSequentialGroup();
	ParallelGroup col1 = gl.createParallelGroup();
	ParallelGroup col2 = gl.createParallelGroup();
	ParallelGroup col3 = gl.createParallelGroup();
	
	for (String a : PARAM_NAMES) {
		JLabel indicator = new JLabel();
		JLabel caption = new JLabel(get("definition.refprop_" + a));
		JTextField textField = new JTextField(10);
		textField.setHorizontalAlignment(JTextField.RIGHT);
		caption.setToolTipText(get("definition.refprop_" + a + ".tip"));
		textField.setToolTipText(get("definition.refprop_" + a + ".tip"));
		
		indicators.put(a, indicator);
		fields.put(a, textField);
		
		ParallelGroup pg = gl.createParallelGroup(Alignment.BASELINE);
		
		col1.addComponent(caption);
		col2.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
		col3.addComponent(indicator, 20, 20, 20);
		
		pg.addComponent(caption);
		pg.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
		pg.addComponent(indicator, 20, 20, 20);
		
		rows.addGroup(pg);
	}
	
	gl.setHorizontalGroup(
		gl.createSequentialGroup()
		.addGroup(col1)
		.addGroup(col2)
		.addGroup(col3)
	);
	gl.setVerticalGroup(rows);

	
	return p;
}
 
Example 16
Source File: DialogAddField.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

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

    JLabel nameLabel = new JLabel(NAME_FIELD_LABEL);
    JLabel valueLabel = new JLabel(VALUE_FIELD_LABEL);
    JLabel enabledLabel = new JLabel(ENABLED_FIELD_LABEL);

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                    .addComponent(nameLabel)
                                    .addComponent(valueLabel)
                                    .addComponent(enabledLabel))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addComponent(getNameTextField())
                                    .addComponent(getValueField())
                                    .addComponent(getEnabledCheckBox())));

    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(nameLabel)
                                    .addComponent(getNameTextField()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(valueLabel)
                                    .addComponent(getValueField()))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(enabledLabel)
                                    .addComponent(getEnabledCheckBox())));

    return fieldsPanel;
}
 
Example 17
Source File: ModifyProcessorDialog.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout groupLayout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(groupLayout);
    groupLayout.setAutoCreateGaps(true);
    groupLayout.setAutoCreateContainerGaps(true);

    JLabel typeLabel = new JLabel(TYPE_LABEL);
    JLabel nameTypeLabel = new JLabel(nameType);

    groupLayout.setHorizontalGroup(
            groupLayout
                    .createParallelGroup()
                    .addGroup(
                            groupLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.TRAILING)
                                                    .addComponent(typeLabel))
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.LEADING)
                                                    .addComponent(nameTypeLabel)))
                    .addComponent(contentPanel.getComponent())
                    .addComponent(previewPanel.getPanel()));

    groupLayout.setVerticalGroup(
            groupLayout
                    .createSequentialGroup()
                    .addGroup(
                            groupLayout
                                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(typeLabel)
                                    .addComponent(nameTypeLabel))
                    .addComponent(contentPanel.getComponent())
                    .addComponent(previewPanel.getPanel()));

    return fieldsPanel;
}
 
Example 18
Source File: MessageLocationPayloadsPanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public MessageLocationPayloadsPanel(
        Window parent,
        MessageLocation messageLocation,
        List<PayloadTableEntry> payloads,
        PayloadGeneratorsContainer payloadGeneratorsUIHandlers) {
    this.parent = parent;
    this.payloadGeneratorsUIHandlers = payloadGeneratorsUIHandlers;
    this.messageLocation = messageLocation;
    this.payloadsTablePanel = new PayloadsTablePanel(payloads);

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

    JLabel locationLabel =
            new JLabel(
                    Constant.messages.getString(
                            "fuzz.fuzzer.dialog.payloads.messagelocation.label.location"));
    JLabel messageLocationLabel = new JLabel(messageLocation.getDescription());
    JLabel valueLabel =
            new JLabel(
                    Constant.messages.getString(
                            "fuzz.fuzzer.dialog.payloads.messagelocation.label.value"));

    JComponent messageLocationValue;
    String value = messageLocation.getValue();
    if (value.length() > 100) {
        JTextArea messageLocationValueTextArea =
                new JTextArea(StringUIUtils.addVisibleNewLineChars(value));
        messageLocationValueTextArea.setColumns(10);
        messageLocationValueTextArea.setRows(5);
        messageLocationValueTextArea.setEditable(false);

        JScrollPane messageLocationValueScrollPane =
                new JScrollPane(messageLocationValueTextArea);
        messageLocationValue = messageLocationValueScrollPane;
    } else {
        JLabel messageLocationValueLabel =
                new JLabel(
                        StringUIUtils.containsNewLineChars(value)
                                ? StringUIUtils.replaceWithVisibleWhiteSpaceChars(value)
                                : value);
        messageLocationValue = messageLocationValueLabel;
    }

    JLabel payloadsLabel =
            new JLabel(
                    Constant.messages.getString("fuzz.fuzzer.dialog.payloads.payloads.label"));

    layout.setHorizontalGroup(
            layout.createParallelGroup()
                    .addGroup(
                            layout.createSequentialGroup()
                                    .addComponent(locationLabel)
                                    .addComponent(messageLocationLabel))
                    .addGroup(
                            layout.createSequentialGroup()
                                    .addComponent(valueLabel)
                                    .addComponent(messageLocationValue))
                    .addComponent(payloadsLabel)
                    .addComponent(payloadsTablePanel));

    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(locationLabel)
                                    .addComponent(messageLocationLabel))
                    .addGroup(
                            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(valueLabel)
                                    .addComponent(messageLocationValue))
                    .addComponent(payloadsLabel)
                    .addComponent(payloadsTablePanel));
}
 
Example 19
Source File: MapHeaderEditorPanel.java    From settlers-remake with MIT License 4 votes vote down vote up
private void generate(boolean sizeChangable) {
	nameField = new JTextField();
	descriptionField = new JTextArea(5, 40);
	descriptionField.setLineWrap(true);
	descriptionField.setWrapStyleWord(true);

	width = new SpinnerNumberModel(DEFAULT_MAPSIZE, MIN_MAPSIZE,
			MAX_MAPSIZE, 1);
	height = new SpinnerNumberModel(DEFAULT_MAPSIZE, MIN_MAPSIZE,
			MAX_MAPSIZE, 1);
	minPlayer = new SpinnerNumberModel(1, 1, CommonConstants.MAX_PLAYERS, 1);
	maxPlayer = new SpinnerNumberModel(1, 1, CommonConstants.MAX_PLAYERS, 1);

	JSpinner widthField = new JSpinner(width);
	JSpinner heightField = new JSpinner(height);
	JSpinner minPlayerField = new JSpinner(minPlayer);
	JSpinner maxPlayerField = new JSpinner(maxPlayer);

	JLabel nameLabel = new JLabel(EditorLabels.getLabel("header.map-name"));
	JLabel descriptionLabel = new JLabel(EditorLabels.getLabel("header.map-description"));
	JLabel widthLabel = new JLabel(EditorLabels.getLabel("header.width"));
	JLabel heightLabel = new JLabel(EditorLabels.getLabel("header.height"));
	JLabel minPlayerLabel = new JLabel(EditorLabels.getLabel("header.map-min-player"));
	JLabel maxPlayerLabel = new JLabel(EditorLabels.getLabel("header.map-max-player"));

	add(nameField);
	add(descriptionField);
	add(heightField);
	add(widthField);
	add(minPlayerField);
	add(maxPlayerField);

	add(nameLabel);
	add(descriptionLabel);
	add(widthLabel);
	add(heightLabel);
	add(maxPlayerLabel);
	add(minPlayerLabel);

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

	// @formatter:off
	layout.setHorizontalGroup(layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup()
					.addComponent(nameLabel)
					.addComponent(descriptionLabel)
					.addComponent(heightLabel)
					.addComponent(widthLabel)
					.addComponent(maxPlayerLabel)
					.addComponent(minPlayerLabel))
			.addGroup(layout.createParallelGroup()
					.addComponent(nameField)
					.addComponent(descriptionField)
					.addComponent(heightField)
					.addComponent(widthField)
					.addComponent(maxPlayerField)
					.addComponent(minPlayerField)));
	layout.setVerticalGroup(layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup()
					.addComponent(nameLabel)
					.addComponent(nameField))
			.addGroup(layout.createParallelGroup()
					.addComponent(descriptionLabel)
					.addComponent(descriptionField))
			.addGroup(layout.createParallelGroup()
					.addComponent(widthLabel)
					.addComponent(widthField))
			.addGroup(layout.createParallelGroup()
					.addComponent(heightLabel)
					.addComponent(heightField))
			.addGroup(layout.createParallelGroup()
					.addComponent(minPlayerLabel)
					.addComponent(minPlayerField))
			.addGroup(layout.createParallelGroup()
					.addComponent(maxPlayerLabel)
					.addComponent(maxPlayerField)));
	// @formatter:on

	if (!sizeChangable) {
		widthField.setEnabled(false);
		heightField.setEnabled(false);
	}
}
 
Example 20
Source File: ModifyFuzzerMessageProcessorDialog.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout groupLayout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(groupLayout);
    groupLayout.setAutoCreateGaps(true);
    groupLayout.setAutoCreateContainerGaps(true);

    JLabel typeLabel = new JLabel(TYPE_LABEL);
    JLabel nameTypeLabel = new JLabel(nameType);

    groupLayout.setHorizontalGroup(
            groupLayout
                    .createParallelGroup()
                    .addGroup(
                            groupLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.TRAILING)
                                                    .addComponent(typeLabel))
                                    .addGroup(
                                            groupLayout
                                                    .createParallelGroup(
                                                            GroupLayout.Alignment.LEADING)
                                                    .addComponent(nameTypeLabel)))
                    .addComponent(contentPanel.getComponent()));

    groupLayout.setVerticalGroup(
            groupLayout
                    .createSequentialGroup()
                    .addGroup(
                            groupLayout
                                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(typeLabel)
                                    .addComponent(nameTypeLabel))
                    .addComponent(contentPanel.getComponent()));

    return fieldsPanel;
}