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:de.codesourcery.jasm16.ide.ui.views.EmulationOptionsView.java

public EmulationOptionsView() {
    emulatorPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    emulatorPanel.add(new JLabel("Emulation speed"), cnstrs);

    cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.WEST;
    emulatorPanel.setBorder(BorderFactory.createTitledBorder("General options"));

    speedBox.setRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(javax.swing.JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            final java.awt.Component result = super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);//from   w w w  .  j a va 2  s  . c o  m

            if (value != null) {
                switch ((EmulationSpeed) value) {
                case MAX_SPEED:
                    setText("Max.");
                    break;
                case REAL_SPEED:
                    setText("100 kHz");
                    break;
                default:
                    setText(value.toString());
                    break;
                }
            }
            return result;
        };
    });

    emulatorPanel.add(speedBox, cnstrs);

    // disk drive panel
    selectedFileField.setColumns(25);

    diskDrivePanel.setLayout(new GridBagLayout());
    cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;

    diskDrivePanel.setBorder(BorderFactory.createTitledBorder("Disk drive"));
    diskDrivePanel.add(selectedFileField, cnstrs);

    cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;
    diskDrivePanel.add(fileChooserButton, cnstrs);

    fileChooserButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            if (getSelectedFile() != null) {
                chooser = new JFileChooser(getSelectedFile().getParentFile());
            } else {
                chooser = new JFileChooser();
            }
            final int result = chooser.showOpenDialog(null);
            if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) {
                selectedFileField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    cnstrs = constraints(2, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;
    diskDrivePanel.add(writeProtected, cnstrs);
}

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

/**
 * @param resources//from   ww  w.j  a  v  a2 s  .com
 * @param processControl
 * @param dispatcherFactory
 * @param TotalOrNot
 * @param agentIdentity
 * @param agentsCollection
 * @throws ConsoleException
 */
public P_WIPSSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, Boolean TotalOrNot, AgentIdentity agentIdentity,
        AgentsCollection agentsCollection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;
    m_agentIdentity = agentIdentity;
    m_agentsCollection = agentsCollection;
    m_agentsCollection.registerObserver(this);

    this.TotalOrNot = TotalOrNot;

    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.jets3t.apps.cockpitlite.ToggleAclDialog.java

/**
 * Initialises all GUI elements./*from www. j  ava2 s .  c o m*/
 */
private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    JHtmlLabel messageLabel = skinsFactory.createSkinnedJHtmlLabel("ToggleAclDialogMessage", hyperlinkListener);
    messageLabel.setText("File privacy setting:");
    messageLabel.setHorizontalAlignment(JLabel.CENTER);

    privateRadioButton = skinsFactory.createSkinnedJRadioButton("ToggleAclDialogPrivateRadioButton");
    privateRadioButton.setText("Private file");
    publicRadioButton = skinsFactory.createSkinnedJRadioButton("ToggleAclDialogPublicRadioButton");
    publicRadioButton.setText("Public file");
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(privateRadioButton);
    buttonGroup.add(publicRadioButton);

    publicRadioButton.setSelected(isPublicObject);
    privateRadioButton.setSelected(!isPublicObject);

    JButton okButton = skinsFactory.createSkinnedJButton("ToggleAclDialogOkButton");
    okButton.setName("OK");
    okButton.setText("OK");
    okButton.addActionListener(this);
    this.getRootPane().setDefaultButton(okButton);

    JPanel buttonsPanel = skinsFactory.createSkinnedJPanel("ToggleAclDialogButtonsPanel");
    buttonsPanel.setLayout(new GridBagLayout());
    buttonsPanel.add(privateRadioButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    buttonsPanel.add(publicRadioButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    buttonsPanel.add(okButton, new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    int row = 0;
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(messageLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));
    this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 1, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    this.pack();
    this.setLocationRelativeTo(this.getOwner());
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java

/**
 * This method initializes this/* w w  w  .j ava2  s.c  om*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.weightx = 0.1;
    gridBagConstraints5.weighty = 0.0;
    gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints5.insets = new Insets(0, 10, 0, 0);
    gridBagConstraints5.gridy = 1;
    GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
    gridBagConstraints41.gridx = 0;
    gridBagConstraints41.weightx = 0.1;
    gridBagConstraints41.anchor = GridBagConstraints.CENTER;
    gridBagConstraints41.insets = new Insets(0, 10, 20, 0);
    gridBagConstraints41.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints41.gridy = 0;
    GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 1;
    gridBagConstraints3.gridheight = 2;
    gridBagConstraints3.anchor = GridBagConstraints.NORTH;
    gridBagConstraints3.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints3.gridy = 0;
    this.setSize(600, 250);
    this.setLayout(new GridBagLayout());
    this.add(getJPanelButton(), gridBagConstraints3);
    this.add(getJPanelPjtName(), gridBagConstraints41);
    this.add(getJPanelSourceLocation(), gridBagConstraints5);

    getJTextFieldSourceLocation().setText(strPath);
    getJTextFieldSourceLocation().setToolTipText(strPath);
}

From source file:rhinova.gui.dataentry.reserve.ReserveDataEntryPanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    vSpacer6 = new JPanel(null);
    label1 = new JLabel();
    hSpacer1 = new JPanel(null);
    label2 = new JLabel();
    txtName = new JTextField();
    vSpacer1 = new JPanel(null);
    label3 = new JLabel();
    txtXPos = new JTextField();
    vSpacer2 = new JPanel(null);
    label4 = new JLabel();
    txtYPos = new JTextField();
    hSpacer2 = new JPanel(null);
    vSpacer3 = new JPanel(null);
    label8 = new JLabel();
    txtMin = new JTextField();
    vSpacer4 = new JPanel(null);
    label5 = new JLabel();
    txtMax = new JTextField();
    vSpacer5 = new JPanel(null);
    label6 = new JLabel();
    txtCur = new JTextField();
    vSpacer9 = new JPanel(null);
    label7 = new JLabel();
    txtReg = new JTextField();
    vSpacer7 = new JPanel(null);
    btnCreateReserve = new JButton();
    vSpacer8 = new JPanel(null);

    //======== this ========
    setBorder(new TitledBorder("Reserve"));
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0 };// w w w.ja  v  a 2  s  .co  m
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 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, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    add(vSpacer6, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label1 ----
    label1.setText("Reserve Entry Panel");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label2 ----
    label2.setText("name");
    add(label2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtName, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer1, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label3 ----
    label3.setText("x - position");
    add(label3, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtXPos, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer2, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label4 ----
    label4.setText("y - position");
    add(label4, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtYPos, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    add(vSpacer3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label8 ----
    label8.setText("minimum population");
    add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtMin, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer4, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label5 ----
    label5.setText("maximum population");
    add(label5, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtMax, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer5, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label6 ----
    label6.setText("current population");
    add(label6, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtCur, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer9, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label7 ----
    label7.setText("regeneration rate");
    add(label7, new GridBagConstraints(1, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtReg, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer7, new GridBagConstraints(1, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- btnCreateReserve ----
    btnCreateReserve.setText("Create Reserve");
    btnCreateReserve.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCreateReserveActionPerformed(e);
        }
    });
    add(btnCreateReserve, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer8, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:ImageOpByRomain.java

private void buildControlsPanel() {
    JPanel controls = new JPanel(new GridBagLayout());

    // red component
    controls.add(new JLabel("Red: 0"), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(redSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // green component
    controls.add(new JLabel("Green: 0"), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(greenSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // blue component
    controls.add(new JLabel("Blue: 0"), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(blueSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // mix value/*from   w  w  w .  j ava 2  s .c o  m*/
    controls.add(new JLabel("Mix: 0%"), new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(alphaSlider = new JSlider(0, 100, 50), new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("100%"), new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // change listener
    ChangeListener colorChange = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            imagePanel.setColor(new Color(redSlider.getValue(), greenSlider.getValue(), blueSlider.getValue()));
        }
    };
    redSlider.addChangeListener(colorChange);
    greenSlider.addChangeListener(colorChange);
    blueSlider.addChangeListener(colorChange);

    // alpha listener
    alphaSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            imagePanel.setMix((float) alphaSlider.getValue() / 100.0f);
        }
    });

    add(controls, BorderLayout.SOUTH);
}

From source file:us.paulevans.basicxslt.SaveAsConfigurationFrame.java

/**
 * Builds the main panel/*from www. j ava 2s . c om*/
 * @return
 */
private JPanel buildMainPanel() {

    int row;
    GridBagLayout layout;
    GridBagConstraints constraints;
    JPanel main;
    JLabel label;

    layout = new GridBagLayout();
    constraints = new GridBagConstraints();
    main = new JPanel(layout);
    row = 0;
    GUIUtils.add(main,
            new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_CURRENT_CONFIGURATION)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.MED_INSETS);
    GUIUtils.add(main, label = new JLabel(userPrefs.getConfiguration()), layout, constraints, row++, 1, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    label.setForeground(Color.BLUE);
    GUIUtils.add(main, new JSeparator(), layout, constraints, row++, 0, 1, 2, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, GUIUtils.MED_INSETS);
    GUIUtils.add(main,
            new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_CONFIGURATION_NAME)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, new JScrollPane(configurationName = new JTextField(20)), layout, constraints, row++, 1,
            1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_MAKE_DEFAULT)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, makeDefault = new JCheckBox(), layout, constraints, row++, 1, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    return main;
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public GridBagConstraints createGridBagConstraint(int gridx, int gridy, Component component, String position) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = gridx;//from www  .  ja  va 2  s .c om
    gbc.gridy = gridy;
    gbc.ipady = 4;
    gbc.insets = new Insets(5, 5, 5, 5);
    if (position.equals("line start"))
        gbc.anchor = GridBagConstraints.LINE_START;
    else if (position.equals("center"))
        gbc.anchor = GridBagConstraints.CENTER;
    else if (position.equals("line end"))
        gbc.anchor = GridBagConstraints.LINE_END;
    return gbc;
}

From source file:net.chaosserver.timelord.swingui.TaskDayPanel.java

/**
 * Builds the panel. This uses a GridBag to try and make formatting
 * grid-like between the unconnected rows.
 *///from   w  w  w  . jav  a2s . co m
protected void buildPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    Insets defaultInsets = gridBagConstraints.insets;

    setLayout(gridBagLayout);

    taskName = new JLabel();

    if (timelordTask.isHidden()) {
        Font taskFont = taskName.getFont();
        Font italicFont = new Font(taskFont.getName(), Font.ITALIC, taskFont.getSize());
        taskName.setFont(italicFont);
    }

    updateTaskNameLabel();
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagLayout.addLayoutComponent(taskName, gridBagConstraints);
    add(taskName);

    minusButton = new JButton("-" + DateUtil.getSmallestTimeInMinutes() + "m");

    minusButton.setToolTipText("Remove 15 minutes (0.25 hours) " + "of time from this task.");
    minusButton.setActionCommand(ACTION_MINUS_15);
    minusButton.addActionListener(this);
    gridBagConstraints.anchor = GridBagConstraints.CENTER;
    gridBagConstraints.insets = defaultInsets;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagLayout.addLayoutComponent(minusButton, gridBagConstraints);
    add(minusButton);

    addButton = new JButton("+" + DateUtil.getSmallestTimeInMinutes() + "m");

    addButton.setToolTipText("Add 15 minutes (0.25 hours) of " + "time from this task.");
    addButton.setActionCommand(ACTION_ADD_15);
    addButton.addActionListener(this);
    gridBagConstraints.anchor = GridBagConstraints.CENTER;
    gridBagConstraints.insets = defaultInsets;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagLayout.addLayoutComponent(addButton, gridBagConstraints);
    add(addButton);

    timeLabel = new JLabel();

    if (todayTaskDay != null) {
        timeLabel.setText(DateUtil.formatHours(null, todayTaskDay.getHours()));
    } else {
        timeLabel.setText(DateUtil.formatHours(null, 0));
    }

    gridBagConstraints.anchor = GridBagConstraints.EAST;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
    gridBagLayout.addLayoutComponent(timeLabel, gridBagConstraints);
    add(timeLabel);

    enabledButtons();
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.commonswing.ExceptionDialog.java

private void init() {
    messages = new Messages(getLocale(), SwingCommonModule.BUNDLE_NAME,
            ObjectUtilities.getClassLoader(SwingCommonModule.class));
    setModal(true);//from   w w w  .j  a v  a  2 s .  c  om
    detailsAction = new DetailsAction();

    messageLabel = new JLabel();
    backtraceArea = new JTextArea();

    scroller = new JScrollPane(backtraceArea);
    scroller.setVisible(false);

    final JPanel detailPane = new JPanel();
    detailPane.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    final JLabel icon = new JLabel(UIManager.getDefaults().getIcon("OptionPane.errorIcon")); //$NON-NLS-1$
    icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    detailPane.add(icon, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.gridx = 1;
    gbc.gridy = 0;
    detailPane.add(messageLabel);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    detailPane.add(createButtonPane(), gbc);

    filler = new JPanel();
    filler.setPreferredSize(new Dimension(0, 0));
    filler.setBackground(Color.green);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    detailPane.add(filler, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    detailPane.add(scroller, gbc);

    setContentPane(detailPane);
}