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.jets3t.gui.ProgressPanel.java

private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {/*  w w w.  j  a v  a  2s. c  om*/
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setLayout(new GridBagLayout());

    statusMessageLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressPanelStatusMessageLabel");
    statusMessageLabel.setText(" ");
    statusMessageLabel.setHorizontalAlignment(JLabel.CENTER);
    this.add(statusMessageLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    progressBar = skinsFactory.createSkinnedJProgressBar("ProgressPanelProgressBar", 0, 100);
    this.add(progressBar, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Display the cancel button if a cancel event listener is available.
    cancelButton = skinsFactory.createSkinnedJButton("ProgressPanelCancelButton");
    guiUtils.applyIcon(cancelButton, "/images/nuvola/16x16/actions/cancel.png");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    cancelButton.setEnabled(cancelEventTrigger != null);

    this.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
}

From source file:ecosim.gui.SummaryPane.java

public SummaryPane(Summary summary) {
    this.summary = summary;
    setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    setLayout(new GridBagLayout());
    // Setup the constraints for the GridBagLayout.
    GridBagConstraints northWest = new GridBagConstraints(0, 0, // gridx, gridy
            1, 1, // gridwidth, gridheight
            0.9D, 0.9D, // weightx, weighty
            GridBagConstraints.CENTER, // anchor
            GridBagConstraints.BOTH, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );//  www . j a  va2s .  co m
    GridBagConstraints northEast = new GridBagConstraints(1, 0, // gridx, gridy
            1, 1, // gridwidth, gridheight
            0.1D, 0.5D, // weightx, weighty
            GridBagConstraints.NORTH, // anchor
            GridBagConstraints.HORIZONTAL, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );
    GridBagConstraints south = new GridBagConstraints(0, 1, // gridx, gridy
            2, 1, // gridwidth, gridheight
            1.0D, 0.1D, // weightx, weighty
            GridBagConstraints.SOUTH, // anchor
            GridBagConstraints.HORIZONTAL, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );
    // Add everything to the summary pane.
    add(makeBinningChart(), northWest);
    add(makeTextPane(), northEast);
    add(makeTablePane(), south);
}

From source file:geneon.intellij.plugin.jenkins.ui.EditServerDialog.java

@Nullable
@Override/*from  ww w  .  ja  v  a2 s.c o  m*/
protected JComponent createCenterPanel() {
    nameTextField.setMinimumSize(new Dimension(300, 10));
    urlTextField.setMinimumSize(new Dimension(300, 10));

    JButton testButton = new JButton("Test");
    testButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testSettings();
        }
    });

    JPanel panel = new JPanel(new GridBagLayout());
    JLabel nameLabel = new JLabel("Server name:");
    panel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
    panel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
    JLabel urlLabel = new JLabel("URL:");
    panel.add(urlLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
    panel.add(urlTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
    panel.add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));

    return panel;
}

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 a2  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:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

@Override
protected JComponent createFormControl() {
    // add field panel
    final JPanel contentPanel = new JPanel(new GridBagLayout());
    int row = 0;/*from   w  ww  .j  a  va2 s.  co  m*/
    final int col = 0;
    GridBagConstraints gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    addFieldPannel = new AddFieldPanel();
    contentPanel.add(addFieldPannel, gbc);

    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPanel.add(new JSeparator(), gbc);

    // bag-info input form
    form = createFormFields();
    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 1, 1, GridBagConstraints.BOTH,
            GridBagConstraints.WEST);
    contentPanel.add(form, gbc);
    return contentPanel;
}

From source file:com.lp.client.frame.component.PanelDiagramm.java

private void jbInit() throws Throwable {
    this.setLayout(new GridBagLayout());
    jpaWorkingOn = new JPanel(new GridBagLayout());
    chartPanel = new ChartPanel(null);
    JPanel panelButtonAction = getToolsPanel();
    getInternalFrame().addItemChangedListener(this);
    this.add(panelButtonAction, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(jpaWorkingOn, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
}

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

/**
 *
 *
 * @param parent//from   ww  w  .j  a  v a  2s . co m
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java

/**
 * @param resources//from   w  ww  .  jav a2s .  co  m
 * @param processControl
 * @param agentsCollection
 * @throws ConsoleException
 */
public R_RealSessionShowSection(Resources resources, ProcessControl processControl,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    testduring = -1;
    resultNumber = 0;

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:org.bench4Q.console.ui.section.R_RealTransactionShowSection.java

/**
 * @param resources/*from w ww . ja  v a  2 s.c o  m*/
 * @param processControl
 * @param agentsCollection
 * @throws ConsoleException
 */
public R_RealTransactionShowSection(Resources resources, ProcessControl processControl,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.setLayout(new GridBagLayout());

    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    testduring = -1;
    resultNumber = 0;

    picPanel = new PicPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1));

}

From source file:width.java

 public void init() {
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();

     setLayout(gridBag);/*from  w  ww  .ja  v a 2s . c om*/

     Label receiverLabel = new Label("Receiver name:", 
                                     Label.RIGHT);
     gridBag.setConstraints(receiverLabel, c);
     add(receiverLabel);

     nameField = new TextField(getParameter("RECEIVERNAME"),
                                            10);
     c.fill = GridBagConstraints.HORIZONTAL;
     gridBag.setConstraints(nameField, c);
     add(nameField);
     nameField.addActionListener(this);

     Button button = new Button("Send message");
     c.gridwidth = GridBagConstraints.REMAINDER; //end row
     c.anchor = GridBagConstraints.WEST; //stick to the 
                                         //text field
     c.fill = GridBagConstraints.NONE; //keep the button 
                                       //small
     gridBag.setConstraints(button, c);
     add(button);
     button.addActionListener(this);

     status = new TextArea(5, 60);
     status.setEditable(false);
     c.anchor = GridBagConstraints.CENTER; //reset to the default
     c.fill = GridBagConstraints.BOTH; //make this big
     c.weightx = 1.0;
     c.weighty = 1.0;
     gridBag.setConstraints(status, c);
     add(status);

     myName = getParameter("NAME");
     Label senderLabel = new Label("(My name is " + myName + ".)",
                                   Label.CENTER);
     c.weightx = 0.0;
     c.weighty = 0.0;
     gridBag.setConstraints(senderLabel, c);
     add(senderLabel);

newline = System.getProperty("line.separator");
 }