Java JPanel Child addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor, Insets insets)

Here you can find the source of addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor, Insets insets)

Description

add GBC

License

Open Source License

Declaration

public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;
import java.awt.GridBagConstraints;

import java.awt.Insets;

import javax.swing.JPanel;

public class Main {
    public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets) {/* www. j a  va2  s.  c  o  m*/
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = anchor;
        gbc.insets = insets;
        gbc.gridx = gridx;
        gbc.gridy = gridy;

        panel.add(component, gbc);

        return component;
    }

    public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets, float weightx) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = anchor;
        gbc.insets = insets;
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        gbc.weightx = weightx;

        panel.add(component, gbc);

        return component;
    }

    public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets, int gridwidth, int gridheight, int fill) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = gridwidth;
        gbc.gridheight = gridheight;
        gbc.anchor = anchor;
        gbc.fill = fill;
        gbc.insets = insets;
        gbc.gridx = gridx;
        gbc.gridy = gridy;

        panel.add(component, gbc);

        return component;
    }

    public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets, int gridwidth, int gridheight, int fill, float weightx, float weighty) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = gridwidth;
        gbc.gridheight = gridheight;
        gbc.anchor = anchor;
        gbc.fill = fill;
        gbc.insets = insets;
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        gbc.weightx = weightx;
        gbc.weighty = weighty;

        panel.add(component, gbc);

        return component;
    }

    public static Component addGBC(JPanel panel, Component component, int gridx, int gridy, int anchor,
            Insets insets, int gridwidth, int gridheight, int fill, float weightx) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = gridwidth;
        gbc.gridheight = gridheight;
        gbc.anchor = anchor;
        gbc.fill = fill;
        gbc.insets = insets;
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        gbc.weightx = weightx;

        panel.add(component, gbc);

        return component;
    }
}

Related

  1. addComponent(JPanel contentPane, GridBagConstraints gbc, JLabel label, JComponent component)
  2. addComponent(JPanel panel, Component c, int x, int y, int width, int height, int ipadx, int ipady, double weightx, double weighty, int fill, int anchor)
  3. addComponents(JPanel panel, JComponent... comps)
  4. addInput2Pane(String label, Component c, JPanel p, int row)
  5. addSection(JPanel panel, String title)
  6. addSpacer(JPanel panel)
  7. addTo(JPanel panel, String label, String value)