Example usage for java.awt GridBagConstraints VERTICAL

List of usage examples for java.awt GridBagConstraints VERTICAL

Introduction

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

Prototype

int VERTICAL

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

Click Source Link

Document

Resize the component vertically but not horizontally.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFrame frame = new JFrame();
    GridBagLayout gbl = new GridBagLayout();

    frame.setLayout(gbl);//from   ww  w .j ava2 s.  c  o  m
    JButton component = new JButton("1");
    frame.add(component);
    frame.add(new JButton("2"));

    gbl.layoutContainer(frame);

    GridBagConstraints gbc = new GridBagConstraints();

    gbc.fill = GridBagConstraints.VERTICAL;

    gbl.setConstraints(component, gbc);
    frame.add(component);

    frame.pack();
    frame.setVisible(true);
}

From source file:GridBagLayoutGridHeight.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container pane = f.getContentPane();
    pane.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    pane.add(new JLabel("First row, first column"), gbc);
    pane.add(new JLabel("First row, second column"), gbc);
    gbc.gridheight = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.VERTICAL;
    pane.add(new JLabel("First row, third column"), gbc);
    gbc.gridx = 0;/*  w  ww  .  j  a  v  a2 s. c  om*/
    gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.NONE;
    pane.add(new JButton("Second row"), gbc);
    pane.add(new JButton("Third row"), gbc);
    f.setSize(600, 300);
    f.setVisible(true);
}

From source file:GridBagWithWeight.java

public static void main(String[] args) {
    JFrame f = new JFrame("Demonstrates the use of fill constraints");
    JPanel p = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 2, 2);
    c.weighty = 1.0;/* w w  w  . j av  a2 s  . c  o m*/
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 2;
    c.fill = GridBagConstraints.BOTH; // Use both horizontal & vertical
    p.add(new JButton("Java"), c);
    c.gridx = 1;
    c.gridheight = 1;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL; // Horizontal only
    p.add(new JButton("Source"), c);
    c.gridy = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE; // Remember to reset to none
    p.add(new JButton("and"), c);
    c.gridx = 2;
    c.fill = GridBagConstraints.VERTICAL; // Vertical only
    p.add(new JButton("Support."), c);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);

    f.getContentPane().add(p);
    f.setSize(600, 200);
    f.show();
}

From source file:Main.java

public Main() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weighty = 0.0;//from w  w w  .  jav a  2 s .  com

    JPanel one = new JPanel();
    one.setPreferredSize(new Dimension(200, 200));
    one.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    JPanel two = new JPanel();
    two.setPreferredSize(new Dimension(200, 200));
    two.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    this.add(one, gbc);

    gbc.gridy = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;

    this.add(two, gbc);

    this.pack();
    this.setVisible(true);
}

From source file:rhinova.gui.dataentry.link.LinkDataEditPannel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    label1 = new JLabel();
    label2 = new JLabel();
    lblId = new JLabel();
    label3 = new JLabel();
    txtName = new JTextField();
    label8 = new JLabel();
    txtCapacity = new JTextField();
    label4 = new JLabel();
    txtSurvivalRate = new JTextField();
    label5 = new JLabel();
    comboReserve1 = new JComboBox<>();
    label6 = new JLabel();
    comboReserve2 = new JComboBox<>();

    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 54, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };

    //---- label1 ----
    label1.setText("Link Properties");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label2 ----
    label2.setText("id");
    add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(lblId, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label3 ----
    label3.setText("name");
    add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtName, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label8 ----
    label8.setText("capacity");
    add(label8, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtCapacity, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label4 ----
    label4.setText("survival rate");
    add(label4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtSurvivalRate, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label5 ----
    label5.setText("reserve 1");
    add(label5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(comboReserve1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label6 ----
    label6.setText("reserve 2");
    add(label6, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 15), 0, 0));
    add(comboReserve2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:org.pentaho.ui.xul.swing.tags.SwingGroupbox.java

public void resetContainer() {

    container.removeAll();/*from   w ww .  j  a  va 2  s . com*/

    if (this.getOrientation() == Orient.VERTICAL) {

        gc = new GridBagConstraints();
        gc.gridy = GridBagConstraints.RELATIVE;
        gc.gridx = 0;
        gc.gridheight = 1;
        gc.gridwidth = GridBagConstraints.REMAINDER;
        int pad = getPadding();
        gc.insets = new Insets(pad, pad, pad, pad);
        gc.fill = GridBagConstraints.HORIZONTAL;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weightx = 1;

    } else {

        gc = new GridBagConstraints();
        gc.gridy = 0;
        gc.gridx = GridBagConstraints.RELATIVE;
        gc.gridheight = GridBagConstraints.REMAINDER;
        gc.gridwidth = 1;
        gc.insets = new Insets(2, 2, 2, 2);
        gc.fill = GridBagConstraints.VERTICAL;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weighty = 1;

    }

}

From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java

public SettingsPanel(final Project prj, Color bgColor) {
    this.prj = prj;
    this.projectConf = prj.getComponent(AliProjectConfiguration.class);

    previewAndConnection = new JPanel(new GridBagLayout());
    previewAndConnection.setOpaque(false);
    GridBagConstraints c2 = new GridBagConstraints();
    c2.gridx = 0;/*from  w  ww.  j a  v a2 s .  co  m*/
    c2.gridy = 1;
    c2.gridwidth = 2;
    c2.weighty = 1;
    c2.fill = GridBagConstraints.VERTICAL;
    JPanel filler = new JPanel();
    filler.setOpaque(false);
    previewAndConnection.add(filler, c2);

    passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    passwordPanel.setBackground(bgColor);
    JLabel label = new JLabel("Password");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    passwordPanel.add(label);
    final JPasswordField password = new JPasswordField(24);
    passwordPanel.add(password);
    JButton connect = new JButton("Login");
    passwordPanel.add(connect);
    final JLabel message = new JLabel();
    passwordPanel.add(message);
    ActionListener connectionAction = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(),
                        projectConf.getUsername(), password.getText());
            } catch (AuthenticationFailed e) {
                message.setText(e.getMessage());
                return;
            }
            projectConf.ALM_PASSWORD = password.getText();
            projectConf.fireChanged();
        }
    };
    password.addActionListener(connectionAction);
    connect.addActionListener(connectionAction);

    restService = prj.getComponent(RestService.class);
    restService.addServerTypeListener(this);

    location = createTextPane(bgColor);
    domain = createTextPane(bgColor);
    project = createTextPane(bgColor);
    username = createTextPane(bgColor);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(bgColor);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    final JTextPane textPane = new JTextPane();
    textPane.setEditorKit(new HTMLEditorKit());
    textPane.setText(
            "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>");
    textPane.setEditable(false);
    textPane.addHyperlinkListener(this);
    textPane.setBackground(bgColor);
    textPane.setCaret(new NonAdjustingCaret());
    panel.add(textPane, BorderLayout.CENTER);

    JPanel content = new JPanel(new BorderLayout());
    content.setBackground(bgColor);
    content.add(panel, BorderLayout.NORTH);
    content.add(previewAndConnection, BorderLayout.WEST);

    preview = new JPanel(new GridBagLayout()) {
        public Dimension getPreferredSize() {
            Dimension dim = super.getPreferredSize();
            // make enough room for the connection status message
            dim.width = Math.max(dim.width, 300);
            return dim;
        }

        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
    };
    connectedTo(restService.getServerTypeIfAvailable());
    preview.setBackground(bgColor);

    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.WEST;
    preview.add(location, c);
    c.gridwidth = 1;
    c.gridy++;
    preview.add(domain, c);
    c.gridy++;
    preview.add(project, c);
    c.gridy++;
    preview.add(username, c);
    c.gridx++;
    c.gridy--;
    c.gridheight = 2;
    c.weightx = 0;
    c.anchor = GridBagConstraints.SOUTHEAST;
    final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png"));
    reload.setListener(new LinkListener() {
        public void linkSelected(LinkLabel linkLabel, Object o) {
            projectConf.fireChanged();
        }
    }, null);
    preview.add(reload, c);

    JPanel previewNorth = new JPanel(new BorderLayout());
    previewNorth.setBackground(bgColor);
    previewNorth.add(preview, BorderLayout.NORTH);

    addToGridBagPanel(0, 0, previewAndConnection, previewNorth);

    setBackground(bgColor);
    setLayout(new BorderLayout());
    add(content, BorderLayout.CENTER);

    onChanged();
    ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this);
    projectConf.addListener(this);
}

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);/*from  w  w w.j  ava2  s.  c o m*/
    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.simplexrepaginator.RepaginateFrame.java

public RepaginateFrame(FileRepaginator repaginator) {
    super("Simplex Repaginator version " + Repaginate.getVersion());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.repaginator = repaginator;

    setJMenuBar(createMenuBar());/*from   ww  w. j a  v  a 2 s. c o m*/

    input = createInputButton();
    repaginate = createRepaginateButton();
    unrepaginate = createUnrepaginateButton();
    output = creatOutputButton();

    setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);

    c.gridwidth = 2;
    add(input, c);

    c.gridy++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.VERTICAL;
    add(repaginate, c);
    c.gridx++;
    add(unrepaginate, c);

    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    add(output, c);

    Runnable r = new Runnable() {
        @Override
        public void run() {
            UpdateChecker uc = new UpdateChecker();
            try {
                if (!uc.isUpdateAvailable())
                    return;
                final JLabel label = new JLabel("<html>Simplex Repaginator version " + uc.getLatestVersion()
                        + " is available.  " + "Choose <b>File > Check For Updates</b> to download.");
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        c.gridy++;
                        c.weighty = 0;
                        c.fill = GridBagConstraints.HORIZONTAL;
                        add(label, c);
                        revalidate();
                    }
                });
            } catch (IOException ioe) {
            }
        }
    };
    new Thread(r).start();

    pack();
    setSize(800, 400);
}

From source file:ui.panel.UILicenseAdd.java

private JPanel createSettingPnl() {
    JPanel panel = p.createPanel(Layouts.gridbag);
    GridBagConstraints g = new GridBagConstraints();

    lblCloud = l.createLabel("Cloud Storage (GB):", SwingConstants.LEFT);
    g.gridx = 0;//w ww .  j  av a 2  s .co  m
    g.gridy = 0;
    g.gridwidth = 2;
    g.insets = new Insets(5, 5, 5, 5);
    g.anchor = g.FIRST_LINE_START;
    panel.add(lblCloud, g);

    lblValidity = l.createLabel("Validity Period (Months):", SwingConstants.LEFT);
    g.gridx = 0;
    g.gridy = 1;
    g.gridwidth = 2;
    g.weighty = 1.0;
    g.insets = new Insets(5, 5, 5, 5);
    panel.add(lblValidity, g);

    lblConcurrentVCA = l.createLabel("Max Concurrent VCA:", SwingConstants.LEFT);
    g.gridx = 0;
    g.gridy = 2;
    g.gridwidth = 2;
    g.weighty = 1.0;
    g.insets = new Insets(5, 5, 5, 5);
    g.anchor = g.LAST_LINE_START;
    panel.add(lblConcurrentVCA, g);

    spnCloud = new JSpinner(new SpinnerNumberModel(1, 0, 1, 1));
    spnCloud.setPreferredSize(new Dimension(50, 25));
    g.gridx = 2;
    g.gridy = 0;
    g.gridwidth = 2;
    g.fill = GridBagConstraints.VERTICAL;
    panel.add(spnCloud, g);

    spnValidity = new JSpinner(new SpinnerNumberModel(24, 1, 24, 1));
    spnValidity.setPreferredSize(new Dimension(50, 25));
    g.gridx = 2;
    g.gridy = 1;
    g.gridwidth = 2;
    g.fill = GridBagConstraints.VERTICAL;
    panel.add(spnValidity, g);

    spnConcurrentVCA = new JSpinner(new SpinnerNumberModel(1, 1, 4, 1));
    spnConcurrentVCA.setPreferredSize(new Dimension(50, 25));
    g.gridx = 2;
    g.gridy = 2;
    g.gridwidth = 2;
    g.fill = GridBagConstraints.VERTICAL;
    panel.add(spnConcurrentVCA, g);

    cbPerpetual = new JCheckBox("Perpetual");
    cbPerpetual.setBackground(CustomColor.NavyBlue.returnColor());
    cbPerpetual.setForeground(CustomColor.Grey.returnColor());
    cbPerpetual.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cbPerpetual.isSelected()) {
                spnValidity.setEnabled(false);
            } else {
                spnValidity.setEnabled(true);
            }
        }
    });
    g.gridx = 5;
    g.gridy = 1;
    g.weighty = 1.0;
    g.fill = GridBagConstraints.VERTICAL;
    panel.add(cbPerpetual, g);

    return panel;
}