Example usage for java.awt GridBagConstraints CENTER

List of usage examples for java.awt GridBagConstraints CENTER

Introduction

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

Prototype

int CENTER

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

Click Source Link

Document

Put the component in the center of its display area.

Usage

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

private void initGUI() {
    try {/*  w  w  w.  j  ava2 s . co  m*/
        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:loadmaprenderer.ResultDisplayChart.java

public void drawChart(List<ResultDataPair> values, String chartTitle, String dataTitle, double average,
        boolean setAverage) {
    this.removeAll();
    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc;// w w  w . j  a v a  2 s .  co m
    if (values == null || values.isEmpty() || allZero(values)) {
        if (values == null || values.isEmpty())
            label.setText("No Selection or No Result Data");
        else
            label.setText("ALL ZERO");
        this.setLayout(new GridBagLayout());
        this.add(label);
        return;
    }
    if (dataLine != null)
        dataLine.clear();
    if (averageLine != null)
        averageLine.clear();
    if (!setAverage)
        average = getAverage(values);
    XYDataset dataset = makeChartDataset(values, dataTitle, average);
    chart = makeChart(dataset, chartTitle, dataTitle);
    ChartPanel cp = new ChartPanel(chart);

    gbc = setGbc(new Insets(0, 0, 0, 0), GridBagConstraints.BOTH, GridBagConstraints.CENTER, 0, 0, 1, 1, 1.0,
            1.0);
    this.add(cp, gbc);
    //this.setPreferredSize(new Dimension(500,150));
}

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

public void resetContainer() {

    container.removeAll();//w  ww  .j a v  a  2s .c  o m

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

}

From source file:org.onehippo.cms7.launcher.LoggingPanel.java

LoggingPanel() {

    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();

    loggingDocument = new PlainDocument();

    constraints.gridx = 0;/*from w  w w. ja v  a 2  s. co m*/
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridwidth = 1;
    constraints.insets = new Insets(2, 4, 2, 2);
    constraints.fill = GridBagConstraints.BOTH;
    final JLabel infoMessge = new JLabel("Application server log, most recent line at the top");
    add(infoMessge, constraints);

    loggingTextArea = new JTextArea(loggingDocument);
    loggingTextArea.setEditable(false);
    loggingScrollPane = new JScrollPane(loggingTextArea);
    loggingScrollPane.setPreferredSize(new Dimension(600, 200));
    loggingScrollPane.setAutoscrolls(true);

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.fill = GridBagConstraints.CENTER;
    add(loggingScrollPane, constraints);
}

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

/** Creates a new instance of TwoStopsGradient */
public TwoStopsGradient() {
    super("Two Stops Gradient");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel(new GridBagLayout());
    JButton button;/*from   w  ww. j av a  2  s  .  c  o m*/
    panel.add(button = new DepthButton("New"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Open"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Save"), new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);

    add(panel);
    setSize(320, 240);
}

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

private void initGUI() {
    try {// www.  j a  v  a  2  s .  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:ClipboardTest.java

public ClipboardTest() {
    super("Clipboard Test");
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);/*from w w  w .  j  ava  2  s .c om*/

    srcText = new TextArea(8, 32);
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(srcText, c);
    add(srcText);

    copyButton = new Button("Copy Above");
    copyButton.setActionCommand("copy");
    copyButton.addActionListener(this);
    c.gridy = 1;
    c.gridwidth = 1;
    gridbag.setConstraints(copyButton, c);
    add(copyButton);

    pasteButton = new Button("Paste Below");
    pasteButton.setActionCommand("paste");
    pasteButton.addActionListener(this);
    pasteButton.setEnabled(false);
    c.gridx = 1;
    gridbag.setConstraints(pasteButton, c);
    add(pasteButton);

    dstText = new TextArea(8, 32);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    gridbag.setConstraints(dstText, c);
    add(dstText);

    pack();
}

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

/**
 * layoutBagVersionSelection./*from w  w w  . j  ava 2  s  .c  o m*/
 *
 * @param contentPane JPanel
 * @param row         int
 */
private static void layoutBagVersionSelection(final JPanel contentPane, final int row) {
    // contents

    GridBagConstraints glbc;

    final JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

From source file:pipeline.parameter_cell_views.FloatSlider.java

public FloatSlider() {
    super();//from w w w .  jav a2  s  .co m
    addMouseWheelListener(e -> {
        int rotation = e.getWheelRotation();

        float change = (maximum - minimum) * 0.001f * rotation * Utils.getMouseWheelClickFactor();

        currentValue += change;

        if (!((e.getModifiers() & java.awt.event.InputEvent.ALT_MASK) > 0)) {
            if (currentValue > maximum)
                currentValue = maximum;
            if (currentValue < minimum)
                currentValue = minimum;
        }

        currentParameter.setValue(new float[] { currentValue, minimum, maximum });

        updateParameterValues();
        currentParameter.fireValueChanged(false, false, true);

    });
    nf.setMaximumFractionDigits(5);
    nf.setMaximumIntegerDigits(8);
    nf.setGroupingUsed(false);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.gridheight = 1;

    c.ipady = 10;
    parameterName = new JLabel("");

    slider = new JSlider(0, 50, 10);
    slider.addChangeListener(new sliderListener());
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(slider, c);
    c.gridwidth = 1;
    c.ipady = 0;

    currentTextValue = new JTextField(slider.getValue());
    currentTextValue.addActionListener(new valueListener());
    Font smallerFont = new Font(currentTextValue.getFont().getName(), currentTextValue.getFont().getStyle(),
            currentTextValue.getFont().getSize() - 2);
    textMinimum = new JTextField("0");
    textMinimum.setFont(smallerFont);
    textMinimum.addActionListener(new minimumListener());
    textMaximum = new JTextField("50");
    textMaximum.setFont(smallerFont);
    textMaximum.addActionListener(new maximumListener());

    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1.0;
    c.weightx = 0.25;
    add(textMinimum, c);

    c.gridx = 2;
    c.gridy = 1;
    c.weighty = 1.0;
    c.weightx = 0.25;
    add(textMaximum, c);

    c.gridx = 1;
    c.gridy = 1;
    c.weighty = 1.0;
    c.weightx = 0.5;
    add(currentTextValue, c);

    parameterName = new JLabel("parameter");
    c.gridx = 0;
    c.gridy = 2;
    c.weighty = 1.0;
    c.weightx = 0.0;
    c.gridwidth = 3;
    add(parameterName, c);

}