Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

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

private void initialize() {
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 2;//from ww w .  ja va2  s  .  c  om
    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:org.altusmetrum.altosuilib_2.AltosUIEnable.java

public void add_units() {
    /* Imperial units setting */

    /* Add label */
    JRadioButton imperial_units = new JRadioButton("Imperial Units", AltosUIPreferences.imperial_units());
    imperial_units.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JRadioButton item = (JRadioButton) e.getSource();
            boolean enabled = item.isSelected();
            AltosUIPreferences.set_imperial_units(enabled);
        }/*ww  w .  j  a v  a  2s  .c  o  m*/
    });
    imperial_units.setToolTipText("Use Imperial units instead of metric");
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1000;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = il;
    add(imperial_units, c);
}

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;/*  www .ja  v a2 s .c o 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.game.ui.views.WeaponEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new "
                    + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);//from   w w  w .j  a va  2s .  c o  m
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Item item : GameBean.weaponDetails) {
        if (item instanceof Weapon) {
            model.addElement(((Weapon) item).getName());
        }
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel weaponDtsLbl = new JLabel("Weapon Details : ");
    weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(weaponDtsLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel weaponTypeLbl = new JLabel("Weapon Type : ");
    panel1.add(weaponTypeLbl, c);
    c.gridx = 1;
    JComboBox weaponType = new JComboBox(Configuration.weaponTypes);
    weaponType.setSelectedIndex(0);
    weaponType.setPreferredSize(name.getPreferredSize());
    System.out.println(name.getPreferredSize());
    panel1.add(weaponType, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel attackRangeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRangeLbl, c);
    c.gridx = 1;
    JTextField attackRange = new JTextField("");
    attackRange.setColumns(20);
    panel1.add(attackRange, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    //        c.fill = GridBagConstraints.BOTH;
    //        c.gridy = 7;
    //        c.weightx = 1;
    //        c.weighty = 1;
    //        panel1.add(new JLabel(""), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}

From source file:com.sshtools.sshterm.SshTermCommandTab.java

/**
 * Creates a new SshToolsConnectionCommandTab object.
 *///from  w  ww . j a  v  a  2  s  . c o m
public SshTermCommandTab() {
    super();

    JPanel main = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);

    Insets ins2 = new Insets(2, 24, 2, 2);
    gbc.weightx = 1.0;
    requestPseudoTerminal.getModel().setSelected(false);
    disconnectOnSessionClose.getModel().setSelected(true);
    UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER);
    group.add(doNothing);
    group.add(startShell);
    group.add(executeCommands);
    startShell.setSelected(true);
    UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = ins2;
    gbc.weighty = 1.0;

    //commands.setLineWrap(true);
    commands.setBorder(BorderFactory.createEtchedBorder());

    JScrollPane scroll = new JScrollPane(commands);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main);
    commands.setRows(8);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:biomine.bmvis2.pipeline.EdgeGoodnessHider.java

public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) {
    double maxEdge = 0;
    for (VisualEdge e : graph.getAllEdges()) {
        maxEdge = Math.max(maxEdge, e.getGoodness());
    }/*from www  .j a va  2s.co  m*/

    final int scale = 100;
    final JSlider limitSlider = new JSlider();
    limitSlider.setMinimum(0);
    limitSlider.setMaximum(scale);
    limitSlider.setValue((int) (limit * scale));
    final JTextField limitText = new JTextField();
    limitText.setEditable(false);
    limitText.setText("" + limit);

    limitSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            limit = limitSlider.getValue() / (double) scale;
            limitText.setText("" + limit);
            v.settingsChanged(false);
        }
    });

    JPanel ret = new JPanel();
    GridBagLayout bag = new GridBagLayout();
    ret.setLayout(bag);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = c.HORIZONTAL;
    ret.add(limitSlider, c);
    c.gridy++;
    ret.add(limitText, c);
    return ret;
}

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

/**
 * layoutSpacer.//from   www . j a va  2s . c  om
 *
 * @param contentPanel JPanel
 * @param row          int
 */
private static void layoutSpacer(final JPanel contentPanel, final int row) {
    GridBagConstraints glbc = new GridBagConstraints();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.WEST);
    final JLabel spacerLabel = new JLabel("");
    contentPanel.add(spacerLabel, glbc);
}

From source file:com.sec.ose.osi.ui.dialog.progress.JDlgProgress.java

/**
 * This method initializes jPanelContent   
 *    /*from   w ww  .  jav a  2s  .  co m*/
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelContent() {
    if (jPanelContent == null) {
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.weighty = 1.0;
        gridBagConstraints1.insets = new Insets(35, 25, 0, 25);
        gridBagConstraints1.gridx = 0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.weightx = 1.0;
        gridBagConstraints2.weighty = 1.0;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.insets = new Insets(35, 25, 0, 25);
        gridBagConstraints2.gridy = 1;

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.insets = new Insets(20, 0, 20, 0);
        gridBagConstraints3.gridy = 2;

        jPanelContent = new JPanel();
        jPanelContent.setLayout(new GridBagLayout());
        jPanelContent.setPreferredSize(new Dimension(350, 150));
        jPanelContent.add(getJTextAreaMessage(), gridBagConstraints1);
        jPanelContent.add(getJButtonCancel(), gridBagConstraints3);
    }
    return jPanelContent;
}

From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java

/**
 * Creates a new SshToolsConnectionKerberosTab object.
 *///from w w w.  j  a  v  a  2s. c  o  m
public SshToolsConnectionKerberosTab() {
    super();

    //  Create the main connection details panel
    JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(0, 2, 2, 2);
    //  enabled option
    //gbc.fill = GridBagConstraints.NONE;
    useKerberos = new JCheckBox("Use MyProxy Kerberos support");
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER);
    //  Host name
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.NONE;

    //  Username
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER);

    JPanel settingsPanel = new JPanel(new GridBagLayout());
    settingsPanel
            .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: "));
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.anchor = GridBagConstraints.NORTHWEST;
    gbc2.insets = new Insets(0, 2, 2, 2);
    gbc2.weightx = 1.0;

    //  realm
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //  kdc
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.weighty = 1.0;
    UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(4, 2, 2, 2);
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel(
            new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER);

}

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 ww  .  j  av  a 2  s  . co  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);
}