Java Code Examples for java.awt.GridBagConstraints#VERTICAL

The following examples show how to use java.awt.GridBagConstraints#VERTICAL . 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: ManeuverChoiceDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private void setupButtons() {
    butOK.addActionListener(this);
    butCancel.addActionListener(this);

    // layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panButtons.setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 5, 5, 5);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.VERTICAL;
    c.ipadx = 20;
    c.ipady = 5;

    c.gridwidth = 1;
    gridbag.setConstraints(butOK, c);
    panButtons.add(butOK);

    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(butCancel, c);
    panButtons.add(butCancel);
}
 
Example 2
Source File: java_awt_GridBagConstraints.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example 3
Source File: java_awt_GridBagConstraints.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example 4
Source File: BombPayloadDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private void setupButtons() {
    butOK.addActionListener(this);
    butCancel.addActionListener(this);

    // layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panButtons.setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 5, 5, 5);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.VERTICAL;
    c.ipadx = 20;
    c.ipady = 5;

    c.gridwidth = 1;
    gridbag.setConstraints(butOK, c);
    panButtons.add(butOK);

    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(butCancel, c);
    panButtons.add(butCancel);
}
 
Example 5
Source File: java_awt_GridBagConstraints.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example 6
Source File: java_awt_GridBagConstraints.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example 7
Source File: CompanionInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ButtonCellEditor(CharacterFacade character)
{
	this.character = character;

	button.addActionListener(this);
	button.setMargin(new Insets(0, 0, 0, 0));

	container.setOpaque(true);
	container.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.weightx = 1;
	gbc.weighty = 1;
	gbc.anchor = GridBagConstraints.EAST;
	gbc.fill = GridBagConstraints.VERTICAL;
	container.add(button, gbc);
}
 
Example 8
Source File: java_awt_GridBagConstraints.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example 9
Source File: JPanelContainer.java    From mts with GNU General Public License v3.0 5 votes vote down vote up
public void addJPanelGeneric (JPanelGeneric jPanelGeneric){
    if(null != jPanelGeneric){
       
        GridBagConstraints gridBagConstraintsTest = new GridBagConstraints();
        gridBagConstraintsTest.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsTest.gridx = 0;
        gridBagConstraintsTest.gridwidth = 1;
        gridBagConstraintsTest.weightx = 1;

        this.listOfPanelGeneric.add(jPanelGeneric);
        this.add(jPanelGeneric, gridBagConstraintsTest);
        this.validate();
        jPanelGeneric.init();
    }
    else{
        GridBagConstraints gridBagConstraintsPadding = new GridBagConstraints();
        gridBagConstraintsPadding.fill = GridBagConstraints.VERTICAL;
        gridBagConstraintsPadding.gridx = 0;
        gridBagConstraintsPadding.gridwidth = 1;
        gridBagConstraintsPadding.weighty = 1;

        JPanel jPanel = new JPanel();
        jPanel.setMinimumSize(new Dimension(0, 0));
        jPanel.setPreferredSize(new Dimension(0, 0));

        this.add(jPanel, gridBagConstraintsPadding);
        this.validate();
    }
}
 
Example 10
Source File: ToggleButtonGroup.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new button group from the given Actions (requires at least two actions).
 *
 * @param preferredSize
 *            the preferredSize of the nested {@link CompositeToggleButton}s or {@code null}
 * @param actions
 *            the action
 */
public ToggleButtonGroup(Dimension preferredSize, Action... actions) {
	if (actions.length < 2) {
		throw new IllegalArgumentException("At least two primary actions must be specified.");
	}

	this.setOpaque(false);
	this.preferredSize = preferredSize;

	primaryButtons = new CompositeToggleButton[actions.length];
	for (int i = 0; i < actions.length; i++) {
		int position;
		if (i == 0) {
			position = SwingConstants.LEFT;
		} else if (i < actions.length - 1) {
			position = SwingConstants.CENTER;
		} else {
			position = SwingConstants.RIGHT;
		}
		primaryButtons[i] = new CompositeToggleButton(actions[i], position);
	}

	// align buttons left to right with no padding
	GridBagLayout layout = new GridBagLayout();
	setLayout(layout);

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.insets = new Insets(0, 0, 0, 0);
	gbc.fill = GridBagConstraints.VERTICAL;
	gbc.weighty = 1;

	for (JToggleButton button : primaryButtons) {
		button.addActionListener(buttonChooser);
		if (preferredSize != null) {
			button.setMinimumSize(preferredSize);
			button.setPreferredSize(preferredSize);
		}
		add(button, gbc);
	}
}
 
Example 11
Source File: ConnectionInfoPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create a description panel.
 */
private JPanel createDescriptionPanel(String header, String description, boolean showDescription) {
	JPanel descPanel = new JPanel(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.anchor = GridBagConstraints.WEST;
	gbc.weightx = 1.0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	JLabel headerLabel = new JLabel(header);
	headerLabel.setFont(OPEN_SANS_SEMIBOLD_14);
	descPanel.add(headerLabel, gbc);

	if (showDescription) {
		gbc.gridy += 1;
		JLabel descLabel = new FixedWidthLabel(300, description);
		descLabel.setFont(OPEN_SANS_12);
		descPanel.add(descLabel, gbc);
		if (!isTypeKnown) {
			descLabel.setForeground(UNKNOWN_TYPE_COLOR);
		}
	}

	gbc.gridy += 1;
	gbc.weighty = 1.0;
	gbc.fill = GridBagConstraints.VERTICAL;
	descPanel.add(new JLabel(), gbc);

	if (!isTypeKnown) {
		headerLabel.setForeground(UNKNOWN_TYPE_COLOR);
	}

	return descPanel;
}
 
Example 12
Source File: MineDensityDialog.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
public MineDensityDialog(JFrame p) {
    super(p, Messages.getString("MineDensityDialog.title"), true); //$NON-NLS-1$
    super.setResizable(false);
    //frame = p;
    butOk.addActionListener(this);
    
    choDensity.removeAllItems();
    for(int i =5; i < 35; i = i + 5) {
        choDensity.addItem(Integer.toString(i));
    }
    choDensity.setSelectedIndex(0);
    
    getContentPane().setLayout(gridbag);
    c.fill = GridBagConstraints.VERTICAL;
    c.insets = new Insets(1, 1, 1, 1);
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(labDensity, c);
    getContentPane().add(labDensity);
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0.0;
    c.weighty = 0.0;
    gridbag.setConstraints(choDensity, c);
    getContentPane().add(choDensity);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.weighty = 0.0;
    gridbag.setConstraints(butOk, c);
    getContentPane().add(butOk);
    pack();
    setLocation(p.getLocation().x + p.getSize().width / 2 - getSize().width
            / 2, p.getLocation().y + p.getSize().height / 2
            - getSize().height / 2);
}
 
Example 13
Source File: XPlottingViewer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void setupDisplay(Plotter p) {
    final JPanel buttonPanel = new JPanel();
    final GridBagLayout gbl = new GridBagLayout();
    buttonPanel.setLayout(gbl);
    setLayout(new BorderLayout());
    plotButton = new JButton(Resources.getText("LBL_DiscardChart")); // NOI18N
    plotButton.addActionListener(this);
    plotButton.setEnabled(true);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.gridx = 0;
    buttonConstraints.gridy = 0;
    buttonConstraints.fill = GridBagConstraints.VERTICAL;
    buttonConstraints.anchor = GridBagConstraints.CENTER;
    gbl.setConstraints(plotButton, buttonConstraints);
    buttonPanel.add(plotButton);

    if (attributeName != null && attributeName.length()!=0) {
        final JPanel plotterLabelPanel = new JPanel();
        final JLabel atlabel = new JLabel(attributeName);
        final GridBagLayout gbl2 = new GridBagLayout();
        plotterLabelPanel.setLayout(gbl2);
        final GridBagConstraints labelConstraints = new GridBagConstraints();
        labelConstraints.gridx = 0;
        labelConstraints.gridy = 0;
        labelConstraints.fill = GridBagConstraints.VERTICAL;
        labelConstraints.anchor = GridBagConstraints.CENTER;
        labelConstraints.ipady = 10;
        gbl2.setConstraints(atlabel, labelConstraints);
        plotterLabelPanel.add(atlabel);
        add(plotterLabelPanel, BorderLayout.NORTH);
    }

    setPlotter(p);
    add(buttonPanel, BorderLayout.SOUTH);
    repaint();
}
 
Example 14
Source File: EmojiLoadProgressPanel.java    From ChatGameFontificator with The Unlicense 4 votes vote down vote up
/**
 * Construct the emote loading/caching progress panel that sits on the bottom of the Emoji tab of the Control Window
 * 
 * @param chat
 *            The chat panel, for repainting after a load
 * @param emojiControlPanel
 *            Used by the reload button
 */
public EmojiLoadProgressPanel(ChatPanel chatPanel, final ControlPanelEmoji emojiControlPanel)
{
    this.chat = chatPanel;

    this.emojiControlPanel = emojiControlPanel;

    this.workerTaskListLoad = new ConcurrentLinkedQueue<EmojiWorker>();
    this.workerTaskListCache = new ConcurrentLinkedQueue<EmojiWorker>();
    this.currentWorker = null;
    this.emojiLogBox = new LogBox();

    this.bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
    this.percentValue = new JLabel(EMPTY_VALUE_TEXT);
    this.percentValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    this.cancelButton = new JButton("Cancel");
    this.cancelButton.setToolTipText("Cancel any emoji or badge loading or caching currently running or queued to run");
    this.manualButton = new JButton("Load/Cache");
    this.manualButton.setToolTipText("Manually load and or cache all emoji and badges");
    this.resetButton = new JButton("Reset");
    this.resetButton.setToolTipText("Reset all work done loading and or caching emoji and badges");
    handleButtonEnables();

    ActionListener bal = new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            JButton source = (JButton) e.getSource();
            if (cancelButton.equals(source))
            {
                if (currentWorker != null)
                {
                    reset();
                }
            }
            else if (resetButton.equals(source))
            {
                workerTaskListLoad.clear();
                workerTaskListCache.clear();
                emojiConfig.resetWorkCompleted();
                log("Reset all loaded and or cached emoji");
                chat.repaint();
            }
            else if (manualButton.equals(source))
            {
                reset();
                emojiControlPanel.loadAndRunEmojiWork();
            }
            handleButtonEnables();
        }
    };

    this.cancelButton.addActionListener(bal);
    this.resetButton.addActionListener(bal);
    this.manualButton.addActionListener(bal);

    setLayout(new GridBagLayout());

    GridBagConstraints gbc = ControlPanelBase.getGbc();
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 0;
    gbc.gridy = 0;
    JPanel workPanel = new JPanel(new GridBagLayout());
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    workPanel.add(this.bar, gbc);
    gbc.gridx++;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    workPanel.add(percentValue, gbc);
    gbc.gridx++;
    workPanel.add(this.cancelButton, gbc);
    gbc.gridx++;
    workPanel.add(this.manualButton, gbc);
    gbc.gridx++;
    workPanel.add(this.resetButton, gbc);

    gbc = ControlPanelBase.getGbc();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    add(emojiLogBox, gbc);
    gbc.gridy++;

    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(workPanel, gbc);
}
 
Example 15
Source File: ConversionStep.java    From kieker with Apache License 2.0 4 votes vote down vote up
private void addAndLayoutComponents() {
	this.setLayout(new GridBagLayout());

	final GridBagConstraints gridBagConstraints = new GridBagConstraints();

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 1.0;
	gridBagConstraints.fill = GridBagConstraints.BOTH;
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 0;
	this.add(this.infoLabel, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.insets.set(5, 5, 0, 0);
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 1;
	this.add(this.performStep, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 2;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridwidth = 1;
	gridBagConstraints.weightx = 0.0;
	this.add(this.graphvizDirectoryLabel, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.gridx = 1;
	gridBagConstraints.gridy = 2;
	gridBagConstraints.weightx = 1.0;
	gridBagConstraints.fill = GridBagConstraints.BOTH;
	this.add(this.graphvizDirectoryField, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.gridx = 2;
	gridBagConstraints.gridy = 2;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 0.0;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	this.add(this.graphvizDirectoryChooseButton, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 3;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	this.add(this.pic2plotDirectoryLabel, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.gridx = 1;
	gridBagConstraints.gridy = 3;
	gridBagConstraints.fill = GridBagConstraints.BOTH;
	this.add(this.pic2plotDirectoryField, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.gridx = 2;
	gridBagConstraints.gridy = 3;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	this.add(this.pic2plotDirectoryChooseButton, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 4;
	this.add(this.outputFormat, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
	gridBagConstraints.anchor = GridBagConstraints.EAST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	gridBagConstraints.gridx = 1;
	gridBagConstraints.gridy = 4;
	this.add(this.outputFormatField, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	gridBagConstraints.gridx = 2;
	gridBagConstraints.gridy = 4;
	this.add(this.expandingPanel1, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.weighty = 1.0;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridx = 0;
	gridBagConstraints.gridy = 5;
	this.add(this.expandingPanel2, gridBagConstraints);
}
 
Example 16
Source File: ChatLounge.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
private void setupMainPanel() {
    setupMap();

    panMain = new JPanel();

    // layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panMain.setLayout(gridbag);

    c.fill = GridBagConstraints.VERTICAL;
    c.insets = new Insets(1, 1, 1, 1);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    gridbag.setConstraints(butOptions, c);
    panMain.add(butOptions);

    JPanel panel1 = new JPanel(new GridBagLayout());
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.WEST;
    panel1.add(lblMapSummary, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(0, 0, 0, 20);
    panel1.add(lblGameYear, c);
    c.gridx = 2;
    panel1.add(lblTechLevel, c);
    c.insets = new Insets(0, 0, 0, 0);
    c.fill = GridBagConstraints.VERTICAL;
    c.gridx = 3;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.NORTHEAST;
    panel1.add(butCompact, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    panMain.add(panel1, c);

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 3;
    gridbag.setConstraints(scrEntities, c);
    panMain.add(scrEntities);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    gridbag.setConstraints(panUnitInfo, c);
    panMain.add(panUnitInfo);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    gridbag.setConstraints(panPlayerInfo, c);
    panMain.add(panPlayerInfo);

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 0.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    gridbag.setConstraints(scrPlayers, c);
    panMain.add(scrPlayers);

    panTabs.add("Select Units", panMain); //$NON-NLS-1$
    panTabs.add("Select Map", panMap); //$NON-NLS-1$
}
 
Example 17
Source File: HardLayoutPane.java    From DroidUIBuilder with Apache License 2.0 4 votes vote down vote up
/**
 * 按照指定的放置位置和占据的网格数,以指定的填充方式添加组件
 * 
 * @param willBeAddTo 要添加的组件
 * @param gridX 水平方向上网格位置
 * @param gridY 垂直方向上网格位置
 * @param gridWidth 水平方向上占据的网格个数
 * @param gridHeight 垂直方向上占据的网格个数
 * @param fill 填充方式
 * @see GridBagConstraints
 */
public Component addTo(Component willBeAddTo, int gridX, int gridY,
	int gridWidth, int gridHeight, int fill)
{
	gbc.gridx = gridX;
	gbc.gridy = gridY;
	gbc.gridwidth = gridWidth;
	gbc.gridheight = gridHeight;
	if (willBeAddTo instanceof javax.swing.JLabel &&
		((JLabel)willBeAddTo).getHorizontalAlignment() == javax.swing.JLabel.RIGHT)
	{
		gbc.anchor = GridBagConstraints.NORTHEAST;
	}
	else
	{
		gbc.anchor = GridBagConstraints.NORTHWEST;
	}
	switch (fill)
	{
		case GridBagConstraints.NONE:
			gbc.weightx = 0.0;
			gbc.weighty = 0.0;
			break;
		case GridBagConstraints.HORIZONTAL:
			gbc.weightx = 1.0;
			gbc.weighty = 0.0;
			break;
		case GridBagConstraints.VERTICAL:
			gbc.weightx = 0.0;
			gbc.weighty = 1.0;
			break;
		default:
			gbc.weightx = 1.0;
			gbc.weighty = 1.0;
	}
	gbc.fill = fill;
	
	//需要增加“回车移动焦点到下一组件上”监听事件
	if (addEnterKeyTrasfer)
		//给其它组件增加(文本组件已经UI里实现了
		addEnterKeyTransferFocusImplExceptText(willBeAddTo);
	this.fixedSubPane.add(willBeAddTo, gbc);
	return willBeAddTo;
}
 
Example 18
Source File: AdditionalFiltersStep.java    From kieker with Apache License 2.0 4 votes vote down vote up
private void addAndLayoutComponents() {
	this.setLayout(new GridBagLayout());

	final GridBagConstraints gridBagConstraints = new GridBagConstraints();

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 1.0;
	gridBagConstraints.fill = GridBagConstraints.BOTH;
	this.add(this.infoLabel, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridwidth = 1;
	gridBagConstraints.weightx = 0.0;
	this.add(this.selectOnlyTraces, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.EAST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 0.0;
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	this.add(this.selectOnlyTracesInput, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridwidth = 1;
	gridBagConstraints.weightx = 0.0;
	this.add(this.filterTraces, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.EAST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 0.0;
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	this.add(this.filterTracesInput, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridwidth = 1;
	gridBagConstraints.weightx = 0.0;
	this.add(this.ignoreBefore, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.EAST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 0.0;
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	this.add(this.ignoreBeforeInput, gridBagConstraints);

	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	gridBagConstraints.gridwidth = 1;
	gridBagConstraints.weightx = 0.0;
	this.add(this.ignoreAfter, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.anchor = GridBagConstraints.EAST;
	gridBagConstraints.insets.set(5, 5, 5, 5);
	gridBagConstraints.weightx = 0.0;
	gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	this.add(this.ignoreAfterInput, gridBagConstraints);

	gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	gridBagConstraints.weighty = 1.0;
	gridBagConstraints.fill = GridBagConstraints.VERTICAL;
	this.add(this.expandingPanel, gridBagConstraints);
}
 
Example 19
Source File: TablePanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the component in the specified cell.
 *
 * @param rowIndex
 * @param columnIndex
 */
private void updateComponent(int rowIndex, int columnIndex) {
	Pair<Integer, Integer> key = new Pair<>(rowIndex, columnIndex);

	// remove old component
	Component oldComponent = mapOfComponents.get(key);
	if (oldComponent != null) {
		innerPanel.remove(oldComponent);
	}

	// add updated component to panel instead
	Component updatedComponent = createComponentForCell(rowIndex, columnIndex);

	// add dimension constraint (if applicable)
	if (isConstraintsUsed()) {
		updatedComponent.setMinimumSize(constraints[columnIndex]);
		updatedComponent.setMaximumSize(constraints[columnIndex]);
		updatedComponent.setPreferredSize(constraints[columnIndex]);
	}

	if (isConstraintsUsed()) {
		gbc.weightx = 0.0;
	} else {
		if (Collection.class.isAssignableFrom(model.getColumnClass(columnIndex))) {
			gbc.weightx = 0.1;
		} else {
			gbc.weightx = 1.0 / model.getColumnCount();
		}
	}
	gbc.weighty = 0.0;
	if (isConstraintsUsed() && fillerMode == FillerMode.NONE) {
		gbc.fill = GridBagConstraints.VERTICAL;
	} else {
		gbc.fill = GridBagConstraints.BOTH;
	}
	gbc.gridx = columnIndex;
	gbc.gridy = rowIndex;
	innerPanel.add(updatedComponent, gbc);
	innerPanel.revalidate();
	innerPanel.repaint();

	mapOfComponents.put(key, updatedComponent);
}
 
Example 20
Source File: Palette.java    From ChatGameFontificator with The Unlicense 4 votes vote down vote up
public Palette(final String label, Color bgColor, ControlPanelBase controlPanel)
{
    super(new GridBagLayout());

    this.control = controlPanel;

    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);

    this.buttonAdd = new JButton("+");
    this.buttonRem = new JButton("-");
    if (label != null)
    {
        this.label = new JLabel(label);
    }
    this.swatchPanel = new SwatchPanel(bgColor);

    gbc.weightx = 0.0;

    if (label != null)
    {
        gbc.gridheight = 2;
        add(this.label, gbc);
        gbc.gridx++;
    }
    gbc.gridheight = 1;
    add(this.buttonAdd, gbc);
    gbc.gridy++;
    add(this.buttonRem, gbc);
    gbc.gridy = 0;
    gbc.gridx++;
    gbc.gridheight = 2;

    paletteScrollPane = new JScrollPane(this.swatchPanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    paletteScrollPane.setPreferredSize(new Dimension(512, getHeight()));

    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.anchor = GridBagConstraints.EAST;
    add(paletteScrollPane, gbc);
    gbc.gridx++;

    ActionListener al = new ActionListener()
    {
        public void actionPerformed(ActionEvent e)
        {
            JButton source = (JButton) e.getSource();

            if (source == buttonAdd)
            {
                Color c = JColorChooser.showDialog(ControlWindow.me, "Add Color to Palette" + (label == null ? "" : " for " + label), swatchPanel.isEmpty() ? null : swatchPanel.getColors().get(swatchPanel.getCount() - 1));
                if (c != null)
                {
                    addColor(c);
                    control.update();
                    validate();
                    repaint();
                }
            }
            else if (source == buttonRem)
            {
                swatchPanel.removeSelectedColors();
                control.update();
                validate();
                repaint();
            }

        }
    };

    this.buttonAdd.addActionListener(al);
    this.buttonRem.addActionListener(al);

}