Example usage for java.awt GridBagConstraints ABOVE_BASELINE

List of usage examples for java.awt GridBagConstraints ABOVE_BASELINE

Introduction

In this page you can find the example usage for java.awt GridBagConstraints ABOVE_BASELINE.

Prototype

int ABOVE_BASELINE

To view the source code for java.awt GridBagConstraints ABOVE_BASELINE.

Click Source Link

Document

Possible value for the anchor field.

Usage

From source file:com.jostrobin.battleships.view.panels.PlacementPanel.java

@Override
public void afterPropertiesSet() throws Exception {
    setLayout(new GridBagLayout());

    battleField = new BattleFieldPanel("");
    GridBagConstraints gamePanelConstraints = new GridBagConstraints();
    gamePanelConstraints.weightx = 0.6;//from   w w w  .  ja  v  a2 s  . co m
    gamePanelConstraints.weighty = 1.0;
    gamePanelConstraints.gridy = y;
    gamePanelConstraints.gridheight = 4;
    gamePanelConstraints.anchor = GridBagConstraints.ABOVE_BASELINE;
    gamePanelConstraints.fill = GridBagConstraints.BOTH;
    add(battleField, gamePanelConstraints);

    rotate = new JButton("Rotate ship");
    rotate.addActionListener(this);
    GridBagConstraints leftButtonConstraints = new GridBagConstraints();
    leftButtonConstraints.gridy = y++;
    leftButtonConstraints.gridx = 1;
    leftButtonConstraints.fill = GridBagConstraints.NONE;
    leftButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE;
    add(rotate, leftButtonConstraints);

    random = new JButton("Random");
    random.addActionListener(this);
    GridBagConstraints randomButtonConstraints = new GridBagConstraints();
    randomButtonConstraints.gridy = y++;
    randomButtonConstraints.gridx = 1;
    randomButtonConstraints.fill = GridBagConstraints.NONE;
    randomButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE;
    random.addActionListener(this);
    add(random, randomButtonConstraints);

    shipsPanel = new ShipsPanel();
    GridBagConstraints shipsPanelConstraints = new GridBagConstraints();
    shipsPanelConstraints.weightx = 1.0;
    shipsPanelConstraints.weighty = 1.0;
    shipsPanelConstraints.anchor = GridBagConstraints.BASELINE;
    shipsPanelConstraints.fill = GridBagConstraints.BOTH;
    shipsPanelConstraints.gridy = y++;
    shipsPanelConstraints.gridx = 1;
    add(shipsPanel, shipsPanelConstraints);

    ready = new JButton("I'm ready");
    ready.addActionListener(this);
    GridBagConstraints readyButtonConstraints = new GridBagConstraints();
    readyButtonConstraints.gridy = y++;
    readyButtonConstraints.gridx = 1;
    readyButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE;
    ready.setEnabled(false);
    add(ready, readyButtonConstraints);

    updateShips();
}