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:org.mbs3.juniuploader.gui.pnlWoWDirectories.java

private void initGUI() {
    try {// w w w. ja v  a2s  .  c om
        GridBagLayout thisLayout = new GridBagLayout();
        this.setLayout(thisLayout);
        {
            /*dlmWoWDirs = new DefaultListModel();
            Vector dirs = frmMain.getUploader().getLocalSystem().getWowDirectories();
            Iterator i =  dirs.iterator();
            while(i.hasNext())
            dlmWoWDirs.addElement(i.next());
            */

            lstWoWDirs = new JList(); //dlmWoWDirs);
            lstWoWDirs.setModel(frmMain.wowDirectories);
            this.add(lstWoWDirs, new GridBagConstraints(1, 1, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            lstWoWDirs.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        }
        {
            btnAddDirectory = new JButton();
            this.add(btnAddDirectory, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnAddDirectory.setText("Add Directory to List");
            btnAddDirectory.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnAddDirectoryActionPerformed(evt);
                }
            });
        }
        {
            btnRemoveSelected = new JButton();
            this.add(btnRemoveSelected, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnRemoveSelected.setText("Remove Selected Directory");
            btnRemoveSelected.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnRemoveSelectedActionPerformed(evt);
                }
            });
        }
        thisLayout.rowWeights = new double[] { 0.0, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 9, 20, 7, 8, 7, 9 };
        thisLayout.columnWeights = new double[] { 0.0, 0.1, 0.0, 0.0, 0.0 };
        thisLayout.columnWidths = new int[] { 11, 20, 9, 217, 11 };
        this.setPreferredSize(new java.awt.Dimension(614, 382));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanReportMain.java

/**
 * This method initializes this/* w w w  .jav  a  2s.  c o m*/
 * 
 * @return void
 */
private void initialize() {
    this.setSize(482, 200);
    this.setLayout(new GridBagLayout());

    GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
    gridBagConstraints11.fill = GridBagConstraints.BOTH;
    gridBagConstraints11.weighty = 1.0;
    gridBagConstraints11.weightx = 1.0;
    gridBagConstraints11.gridx = 0;
    gridBagConstraints11.gridy = 0;
    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 10;
    gridBagConstraints1.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints1.anchor = GridBagConstraints.NORTH;
    gridBagConstraints1.gridy = 0;

    this.add(getJSplitPane(), gridBagConstraints11);
    this.add(getJPanelbutton(), gridBagConstraints1);

}

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:MessageViewer.java

public MessageViewer(Message what) {
    // set our layout
    super(new GridBagLayout());

    // add the toolbar
    addToolbar();//from ww w  .j a v  a2  s .  c  o  m

    GridBagConstraints gb = new GridBagConstraints();
    gb.gridwidth = GridBagConstraints.REMAINDER;
    gb.fill = GridBagConstraints.BOTH;
    gb.weightx = 1.0;
    gb.weighty = 0.0;

    // add the headers
    headers = new TextArea("", 4, 80, TextArea.SCROLLBARS_NONE);
    headers.setEditable(false);
    add(headers, gb);

    // now display our message
    setMessage(what);
}

From source file:org.mbs3.juniuploader.gui.pnlMainMenu.java

private void initGUI() {
    try {//from   ww w . j a  v  a  2s .  co  m
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.1, 0.1, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 10, 7, 7, 7, 9 };
        thisLayout.columnWeights = new double[] { 0.0, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.columnWidths = new int[] { 12, 7, 10, 7, 11 };
        this.setLayout(thisLayout);
        {
            btnPerfUpload = new JButton();
            this.add(btnPerfUpload, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnPerfUpload.setText("Perform Upload Rules");
            btnPerfUpload.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnPerfUploadActionPerformed(evt);
                }
            });
        }
        {
            btnChkUploads = new JButton();
            this.add(btnChkUploads, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnChkUploads.setText("Check for Program Updates");
            btnChkUploads.setEnabled(false);
        }
        {
            btnSyncUAInterface = new JButton();
            this.add(btnSyncUAInterface, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnSyncUAInterface.setText("Sync with UniAdmin Interface");
            btnSyncUAInterface.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnSyncUAInterfaceActionPerformed(evt);
                }
            });
        }
        {
            btnEraseSettings = new JButton();
            this.add(btnEraseSettings, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnEraseSettings.setText("Erase Saved Settings (causes exit)");
            btnEraseSettings.setEnabled(false);
            btnEraseSettings.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnEraseSettingsActionPerformed(evt);
                }
            });
            //btnEraseSettings.setEnabled(false);
        }
        {
            btnLaunchWoW = new JButton();
            this.add(btnLaunchWoW, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnLaunchWoW.setText("Launch WoW");
            btnLaunchWoW.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnLaunchWoWActionPerformed(evt);
                }
            });
            //btnLaunchWoW.setEnabled(false);
        }
        {
            btnExit = new JButton();
            this.add(btnExit, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            btnExit.setText("Exit Program");
            btnExit.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnExitActionPerformed(evt);
                }
            });
        }
        this.setPreferredSize(new java.awt.Dimension(645, 376));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.monkeys.gui.PopupWindow.java

public void setPanel(final JPanel panel) {
    this.panel = panel;
    this.getContentPane().removeAll();

    if (null == panel) {
        return;//from w  w w. j  a  va  2s.c  o  m
    }

    Dimension size = panel.getPreferredSize();
    if (null == size) {
        size = panel.getSize();
    }
    if (size != null) {
        this.setSize(size);
        this.setPreferredSize(size);
    }

    final GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    this.setLayout(new GridBagLayout());
    this.getContentPane().add(panel, c);
}

From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.ViewFrame.java

public ViewFrame(String title, final IView component) {
    super(title);
    if (component == null) {
        throw new IllegalArgumentException("component must not be NULL.");
    }//from w  ww . jav a 2s . co  m
    this.component = component;

    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            disposeView(component);
            helper.fireViewContainerClosed(ViewFrame.this);
        }
    });

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    final GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.weightx = 1.0d;
    cnstrs.weighty = 1.0d;
    cnstrs.fill = GridBagConstraints.BOTH;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridx = 0;
    cnstrs.gridy = 0;
    panel.add(component.getPanel(this), cnstrs);
    getContentPane().add(panel);
    pack();
}

From source file:ModalMessage.java

/**
 * This method initializes jPanel /*  w w w. ja v a  2  s  . co m*/
 *  
 * @return javax.swing.JPanel 
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.gridx = 0; // Generated
        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; // Generated
        gridBagConstraints1.gridy = 1; // Generated
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; // Generated
        gridBagConstraints.gridy = 0; // Generated
        gridBagConstraints.weightx = 1.0; // Generated
        gridBagConstraints.weighty = 1.0; // Generated
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); // Generated
        gridBagConstraints.gridx = 0; // Generated
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout()); // Generated
        jPanel.add(getJScrollPane(), gridBagConstraints); // Generated
        jPanel.add(getButtonPanel(), gridBagConstraints1);
    }
    return jPanel;
}

From source file:TreeExpandEventDemo2.java

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

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;//  w  ww.j  a va  2 s .c  o m
    c.weighty = 1.0;

    c.insets = new Insets(1, 1, 1, 1);
    demoArea = new DemoArea();
    gridbag.setConstraints(demoArea, c);
    add(demoArea);

    c.insets = new Insets(0, 0, 0, 0);
    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(200, 75));
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

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

From source file:org.apache.marmotta.splash.common.ui.MessageDialog.java

public static void show(String title, String message, String description) {
    final JDialog dialog = new JDialog((Frame) null, title);
    dialog.setModal(true);/*from   ww w .  j av a2s. co  m*/
    dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    final JPanel root = new JPanel(new GridBagLayout());
    root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    dialog.getRootPane().setContentPane(root);

    final JButton close = new JButton("OK");
    close.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });
    GridBagConstraints cClose = new GridBagConstraints();
    cClose.gridx = 0;
    cClose.gridy = 2;
    cClose.gridwidth = 2;
    cClose.weightx = 1;
    cClose.weighty = 0;
    cClose.insets = new Insets(5, 5, 5, 5);

    root.add(close, cClose);
    dialog.getRootPane().setDefaultButton(close);

    Icon icon = loadIcon(MARMOTTA_ICON);
    if (icon != null) {
        JLabel lblIcn = new JLabel(icon);

        GridBagConstraints cIcon = new GridBagConstraints();
        cIcon.gridx = 1;
        cIcon.gridy = 0;
        cIcon.gridheight = 2;
        cIcon.fill = GridBagConstraints.NONE;
        cIcon.weightx = 0;
        cIcon.weighty = 1;
        cIcon.anchor = GridBagConstraints.NORTH;
        cIcon.insets = new Insets(10, 5, 5, 0);
        root.add(lblIcn, cIcon);
    }

    JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>"));
    lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f));
    GridBagConstraints cLabel = new GridBagConstraints();
    cLabel.gridx = 0;
    cLabel.gridy = 0;
    cLabel.fill = GridBagConstraints.BOTH;
    cLabel.weightx = 1;
    cLabel.weighty = 0.5;
    cLabel.insets = new Insets(5, 5, 5, 5);
    root.add(lblMsg, cLabel);

    JLabel lblDescr = new JLabel(
            "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>"));
    cLabel.gridy++;
    cLabel.insets = new Insets(0, 5, 5, 5);
    root.add(lblDescr, cLabel);

    dialog.pack();
    dialog.setLocationRelativeTo(null);

    dialog.setVisible(true);
    dialog.dispose();
}