Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

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

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProxySetting.java

private void initialize() {
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 2;//from  w  w  w .j  av a 2  s  .co  m
    gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints9.gridwidth = 2;
    gridBagConstraints9.insets = new Insets(10, 10, 0, 10);
    gridBagConstraints9.anchor = GridBagConstraints.NORTH;
    gridBagConstraints9.gridy = 0;
    GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
    gridBagConstraints7.gridx = 0;
    gridBagConstraints7.fill = GridBagConstraints.BOTH;
    gridBagConstraints7.gridwidth = 2;
    gridBagConstraints7.insets = new Insets(0, 0, 0, 0);
    gridBagConstraints7.weightx = 1.0;
    gridBagConstraints7.anchor = GridBagConstraints.CENTER;
    gridBagConstraints7.weighty = 1.0;
    gridBagConstraints7.gridy = 0;
    this.setLayout(new GridBagLayout());
    this.add(getJPanelValue(), gridBagConstraints7);
    this.add(getJPanelButtons(), gridBagConstraints9);
}

From source file:com.github.pemapmodder.pocketminegui.gui.server.ServerMainActivity.java

@Override
protected void onStart() {
    lifetime = new ServerLifetime(this);

    //      setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    setLayout(new GridBagLayout());
    JMenuBar bar = new JMenuBar();
    JMenu serverMenu = new JMenu("Server");
    serverMenu.setMnemonic(KeyEvent.VK_S);
    JMenu playerMenu = new JMenu("Players");
    playerMenu.setMnemonic(KeyEvent.VK_P);
    bar.add(serverMenu);/*  w  w  w. j a va  2 s .  c om*/
    bar.add(playerMenu);
    setJMenuBar(bar);

    startStopButton = new JButton("Start");
    startStopButton.addActionListener(lifetime::listen);
    GridBagConstraints constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 0;
    constr.fill = GridBagConstraints.VERTICAL;
    constr.weighty = 0.02;
    constr.weightx = 0.1;
    add(startStopButton, constr);
    constr.gridx = 1;
    constr.gridy = 1;
    constr.fill = GridBagConstraints.BOTH;
    constr.weightx = 0.8;
    constr.weighty = 0.9;
    add(consolePanel = new ConsolePanel(this), constr);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JPanIdentifyResetComment.java

private void initialize() {

    GridBagConstraints gridBagConstraintsPanelComment = new GridBagConstraints();
    gridBagConstraintsPanelComment.fill = GridBagConstraints.BOTH;
    gridBagConstraintsPanelComment.gridx = 0;
    gridBagConstraintsPanelComment.gridy = 0;
    gridBagConstraintsPanelComment.weightx = 1.0;
    gridBagConstraintsPanelComment.weighty = 1.0;

    GridBagConstraints gridBagConstraintsOKResetBtn = new GridBagConstraints();
    gridBagConstraintsOKResetBtn.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraintsOKResetBtn.insets = new Insets(10, 10, 0, 10);
    gridBagConstraintsOKResetBtn.gridx = 1;
    gridBagConstraintsOKResetBtn.gridy = 0;

    this.setLayout(new GridBagLayout());
    this.add(getJScrollPaneComment(), gridBagConstraintsPanelComment);
    this.add(getJPanelOkResetBtn(), gridBagConstraintsOKResetBtn);
}

From source file:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

@Override
protected JComponent createFormControl() {
    // add field panel
    final JPanel contentPanel = new JPanel(new GridBagLayout());
    int row = 0;/*  w w  w.  ja  v  a  2s  .  c o m*/
    final int col = 0;
    GridBagConstraints gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    addFieldPannel = new AddFieldPanel();
    contentPanel.add(addFieldPannel, gbc);

    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPanel.add(new JSeparator(), gbc);

    // bag-info input form
    form = createFormFields();
    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 1, 1, GridBagConstraints.BOTH,
            GridBagConstraints.WEST);
    contentPanel.add(form, gbc);
    return contentPanel;
}

From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java

/**
 * @param resources//from   w w  w .  j a  v  a2 s .c om
 * @param processControl
 * @param agentsCollection
 * @throws ConsoleException
 */
public R_RealSessionShowSection(Resources resources, ProcessControl processControl,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    testduring = -1;
    resultNumber = 0;

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:org.bench4Q.console.ui.section.R_RealTransactionShowSection.java

/**
 * @param resources/*from w w w .java2s  . co m*/
 * @param processControl
 * @param agentsCollection
 * @throws ConsoleException
 */
public R_RealTransactionShowSection(Resources resources, ProcessControl processControl,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    testduring = -1;
    resultNumber = 0;

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:Main.java

public Main() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    // Initialize an empty list of buttons.
    buttonList = new Vector<JButton>(10, 10);

    // Create all the components.
    addButton = new JButton("Add a button");
    addButton.setActionCommand(ADD);//  www .j  a va 2s.  c o  m
    addButton.addActionListener(this);

    removeButton = new JButton("Remove a button");
    removeButton.setActionCommand(REMOVE);
    removeButton.addActionListener(this);

    buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.setPreferredSize(new Dimension(200, 75));
    buttonPanel.addContainerListener(this);

    display = new JTextArea();
    display.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(display);
    scrollPane.setPreferredSize(new Dimension(200, 75));

    clearButton = new JButton("Clear text area");
    clearButton.setActionCommand(CLEAR);
    clearButton.addActionListener(this);

    c.fill = GridBagConstraints.BOTH; // Fill entire cell.
    c.weighty = 1.0; // Button area and message area have equal height.
    c.gridwidth = GridBagConstraints.REMAINDER; // end of row
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    c.weighty = 0.0;
    gridbag.setConstraints(clearButton, c);
    add(clearButton);

    c.weightx = 1.0; // Add/remove buttons have equal width.
    c.gridwidth = 1; // NOT end of row
    gridbag.setConstraints(addButton, c);
    add(addButton);

    c.gridwidth = GridBagConstraints.REMAINDER; // end of row
    gridbag.setConstraints(removeButton, c);
    add(removeButton);

    c.weighty = 1.0; // Button area and message area have equal height.
    gridbag.setConstraints(buttonPanel, c);
    add(buttonPanel);

    setPreferredSize(new Dimension(400, 400));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:ContainerEventDemo.java

public ContainerEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    // Initialize an empty list of buttons.
    buttonList = new Vector<JButton>(10, 10);

    // Create all the components.
    addButton = new JButton("Add a button");
    addButton.setActionCommand(ADD);//from w ww  . j a va  2s.  co  m
    addButton.addActionListener(this);

    removeButton = new JButton("Remove a button");
    removeButton.setActionCommand(REMOVE);
    removeButton.addActionListener(this);

    buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.setPreferredSize(new Dimension(200, 75));
    buttonPanel.addContainerListener(this);

    display = new JTextArea();
    display.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(display);
    scrollPane.setPreferredSize(new Dimension(200, 75));

    clearButton = new JButton("Clear text area");
    clearButton.setActionCommand(CLEAR);
    clearButton.addActionListener(this);

    c.fill = GridBagConstraints.BOTH; // Fill entire cell.
    c.weighty = 1.0; // Button area and message area have equal height.
    c.gridwidth = GridBagConstraints.REMAINDER; // end of row
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    c.weighty = 0.0;
    gridbag.setConstraints(clearButton, c);
    add(clearButton);

    c.weightx = 1.0; // Add/remove buttons have equal width.
    c.gridwidth = 1; // NOT end of row
    gridbag.setConstraints(addButton, c);
    add(addButton);

    c.gridwidth = GridBagConstraints.REMAINDER; // end of row
    gridbag.setConstraints(removeButton, c);
    add(removeButton);

    c.weighty = 1.0; // Button area and message area have equal height.
    gridbag.setConstraints(buttonPanel, c);
    add(buttonPanel);

    setPreferredSize(new Dimension(400, 400));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:net.daboross.outputtablesclient.gui.OutputInterface.java

public OutputInterface(final Application application) {
    this.application = application;

    // persistEnabled
    JSONObject parentObj = application.getPersist().getStorageObject();
    JSONObject tempPersistEnabled = parentObj.optJSONObject("last-shown-panels");
    if (tempPersistEnabled == null) {
        tempPersistEnabled = new JSONObject();
        parentObj.put("last-shown-panels", tempPersistEnabled);
    }// w  w w.j  av a2s  .  c  om
    persistEnabled = tempPersistEnabled;

    // constraints
    toggleButtonConstraints = new GBC().ipadx(2).ipady(2).gridx(0).gridy(-1)
            .fill(GridBagConstraints.HORIZONTAL);
    tablePanelConstraints = new GBC().gridx(0).gridy(-1).weightx(1).weighty(0).anchor(GridBagConstraints.EAST)
            .fill(GridBagConstraints.HORIZONTAL);

    // mainTabPanel
    mainTabPanel = new JPanel();
    mainTabPanel.setLayout(new GridBagLayout());
    application.getRoot().getMainPanel().add(mainTabPanel,
            new GBC().weightx(1).weighty(1).fill(GridBagConstraints.BOTH).gridx(0).gridy(1));

    // toggleButtonPanel
    toggleButtonPanel = new JPanel();
    toggleButtonPanel.setLayout(new GridBagLayout());
    mainTabPanel.add(toggleButtonPanel, new GBC().weightx(0).weighty(0).gridx(0).gridy(0)
            .insets(new Insets(0, 0, 10, 10)).anchor(GridBagConstraints.NORTHWEST));

    // tableRootPanel
    tableRootPanel = new JPanel(new GridBagLayout());
    mainTabPanel.add(tableRootPanel, new GBC().weightx(1).weighty(1).fill(GridBagConstraints.BOTH).gridx(2)
            .gridy(0).anchor(GridBagConstraints.EAST));

    // maps
    tableKeyToTableButton = new TreeMap<>();
    tableKeyToTableEnabled = new TreeMap<>();
    tableKeyToTablePanel = new HashMap<>();
    tableKeyAndKeyToValuePanel = new HashMap<>();
    tableKeyAndKeyToValueLabel = new HashMap<>();
    tableKeyToTableTitledBoarder = new HashMap<>();
}

From source file:DocumentEventDemo.java

public DocumentEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    JButton button = new JButton("Clear");
    button.addActionListener(this);

    textField = new JTextField(20);
    textField.addActionListener(new MyTextActionListener());
    textField.getDocument().addDocumentListener(new MyDocumentListener());
    textField.getDocument().putProperty("name", "Text Field");

    textArea = new JTextArea();
    textArea.getDocument().addDocumentListener(new MyDocumentListener());
    textArea.getDocument().putProperty("name", "Text Area");

    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setPreferredSize(new Dimension(200, 75));

    displayArea = new JTextArea();
    displayArea.setEditable(false);//from   w w  w .  ja  v a 2  s.  c  om
    JScrollPane displayScrollPane = new JScrollPane(displayArea);
    displayScrollPane.setPreferredSize(new Dimension(200, 75));

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(textField, c);
    add(textField);

    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridheight = 2;
    c.fill = GridBagConstraints.BOTH;
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.weighty = 1.0;
    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);

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

    setPreferredSize(new Dimension(450, 250));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}