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.freeplane.core.ui.components.OptionalDontShowMeAgainDialog.java

private OptionalDontShowMeAgainDialog show() {
    final String property = getProperty();
    if (StringUtils.equals(property, "true")) {
        mResult = JOptionPane.OK_OPTION;
        return this;
    }// w  w  w  .j a v a 2 s. com
    if (mMessageType == BOTH_OK_AND_CANCEL_OPTIONS_ARE_STORED && StringUtils.equals(property, "false")) {
        mResult = JOptionPane.CANCEL_OPTION;
        return this;
    }
    mDialog = null;
    mDialog = new JDialog(mParent, TextUtils.getText(mTitleId));
    mDialog.setModal(true);
    mDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    final AbstractAction cancelAction = new AbstractAction() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent pE) {
            close(JOptionPane.CANCEL_OPTION);
        }
    };
    final AbstractAction okAction = new AbstractAction() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent pE) {
            close(JOptionPane.OK_OPTION);
        }
    };
    UITools.addEscapeActionToDialog(mDialog, cancelAction);
    mDialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent pE) {
            close(JOptionPane.CANCEL_OPTION);
        }
    });
    mDialog.getContentPane().setLayout(new GridBagLayout());
    mDialog.getContentPane().add(new JLabel(TextUtils.getText(mMessageId)), new GridBagConstraints(1, 0, 1, 1,
            1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
    final ImageIcon questionMark;
    if (mMessageType == ONLY_OK_SELECTION_IS_SHOWN) {
        questionMark = new ImageIcon(
                ResourceController.getResourceController().getResource("/images/icons/messagebox_warning.png"));
    } else {
        questionMark = new ImageIcon(
                ResourceController.getResourceController().getResource("/images/icons/help.png"));
    }
    mDialog.getContentPane().add(new JLabel(questionMark), new GridBagConstraints(0, 0, 1, 2, 1.0, 2.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
    String boxString;
    if (mMessageType != OptionalDontShowMeAgainDialog.BOTH_OK_AND_CANCEL_OPTIONS_ARE_STORED) {
        boxString = "OptionalDontShowMeAgainDialog.dontShowAgain";
    } else {
        boxString = "OptionalDontShowMeAgainDialog.rememberMyDescision";
    }
    mDontShowAgainBox = new JCheckBox(TextUtils.getRawText(boxString));
    MenuBuilder.setLabelAndMnemonic(mDontShowAgainBox, null);
    mDialog.getContentPane().add(mDontShowAgainBox, new GridBagConstraints(0, 2, 3, 1, 1.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
    final String okText;
    if (mMessageType == ONLY_OK_SELECTION_IS_SHOWN) {
        okText = TextUtils.getRawText("ok");
    } else {
        okText = TextUtils.getRawText("OptionalDontShowMeAgainDialog.ok");
    }
    final JButton okButton = new JButton(okText);
    MenuBuilder.setLabelAndMnemonic(okButton, null);
    okButton.addActionListener(okAction);
    mDialog.getContentPane().add(okButton, new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
    if (mMessageType != ONLY_OK_SELECTION_IS_SHOWN) {
        final JButton cancelButton = new JButton(TextUtils.getRawText("OptionalDontShowMeAgainDialog.cancel"));
        MenuBuilder.setLabelAndMnemonic(cancelButton, null);
        cancelButton.addActionListener(cancelAction);
        mDialog.getContentPane().add(cancelButton, new GridBagConstraints(3, 3, 1, 1, 1.0, 1.0,
                GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
    }
    mDialog.getRootPane().setDefaultButton(okButton);
    mDialog.pack();
    if (mNode != null) {
        UITools.setDialogLocationRelativeTo(mDialog, mNode);
    } else {
        mDialog.setLocationRelativeTo(null);
    }
    mDialog.setVisible(true);
    return this;
}

From source file:fxts.stations.util.preferences.EditAction.java

public void actionPerformed(ActionEvent aEvent) {
    JButton okButton = UIManager.getInst().createButton();
    JButton cancelButton = UIManager.getInst().createButton();
    final JDialog dialog = new JDialog(mEditorPanel.getParentDialog());
    dialog.setTitle(mEditorPanel.getTitle());
    JPanel editPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    //mainPanel.setLayout(new SideLayout());

    //sets button panel
    buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    okButton.setText(mResMan.getString("IDS_OK_BUTTON"));
    //okButton.setPreferredSize(new Dimension(80, 27));
    GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;//from   w  w  w .  j  ava 2 s .co m
    sideConstraints.gridy = 0;
    ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(okButton, sideConstraints);
    cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON"));
    //cancelButton.setPreferredSize(new Dimension(80, 27));
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 1;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.5, 0.0, 0.5, 0.0);
    resizeParameter.setToConstraints(sideConstraints);
    buttonPanel.add(cancelButton, sideConstraints);

    //adds button panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.insets = new Insets(10, 10, 10, 10);
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 1;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 1.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(buttonPanel, sideConstraints);

    //sets edit panel
    final IEditor editor = mType.getEditor();
    editor.setValue(mValue);
    editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    Component editComp = editor.getComponent();

    //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4.
    if (editComp instanceof FontChooser) {
        FontChooser fc = (FontChooser) editComp;
        fc.setNextFocusedComp(okButton);
    }
    editPanel.add(editComp, sideConstraints);

    //adds editor panel
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.gridx = 0;
    sideConstraints.gridy = 0;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    mainPanel.add(editPanel, sideConstraints);

    //adds main panel
    dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout());
    //dialog.getContentPane().setLayout(new SideLayout());
    sideConstraints = UIFrontEnd.getInstance().getSideConstraints();
    sideConstraints.fill = GridBagConstraints.BOTH;
    resizeParameter = UIFrontEnd.getInstance().getResizeParameter();
    resizeParameter.init(0.0, 0.0, 1.0, 1.0);
    resizeParameter.setToConstraints(sideConstraints);
    dialog.getContentPane().add(mainPanel, sideConstraints);

    //adds listeners to buttons
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (editor.getValue().equals(mValue)) {
                //
            } else {
                mValue = editor.getValue();
                mEditorPanel.setValue(mValue);
                mEditorPanel.refreshControls();
                mEditorPanel.setValueChanged(true);
            }
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ExitAction");
    okButton.getActionMap().put("ExitAction", new AbstractAction() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    okButton.requestFocus();
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            editor.setValue(mValue);
            dialog.setVisible(false);
            dialog.dispose();
        }
    });
    //dialog.setResizable(false);
    dialog.setModal(true);
    dialog.pack();

    //sets minimal sizes for components
    Dimension dim = mainPanel.getSize();
    mainPanel.setMinimumSize(dim);
    mainPanel.setPreferredSize(dim);

    //sets size of buttons
    Dimension dimOkButton = okButton.getSize();
    Dimension dimCancelButton = cancelButton.getSize();
    int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth()
            : (int) dimCancelButton.getWidth();
    okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight()));
    cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight()));
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setVisible(true);
}

From source file:org.n52.oxf.ui.swing.ReducedChartDialog.java

/**
 * initializes (or updates) the JFreeChart->ChartPanel.
 * /*  w  ww.  j a  va  2  s  .  c  o m*/
 * @param parameters
 * @param selectedfeatures
 */
private void initChartPanel(OXFFeatureCollection observations, ParameterContainer paramCon) {

    // String[] foiIdArray = (String[])
    // paramCon.getParameterShellWithServiceSidedName("featureOfInterest").getSpecifiedValueArray();

    MyGridBagLayout mainLayout = (MyGridBagLayout) getContentPane().getLayout();

    if (getContentPane().getComponentCount() > 2) {
        getContentPane().remove(2);
    }

    JFreeChart chart = chartRenderer.renderChart(observations, paramCon);
    org.jfree.chart.ChartPanel chartPanel = new org.jfree.chart.ChartPanel(chart);
    chartPanel.setMouseZoomable(true, false);

    mainLayout.addComponent(0, chartPanel, 0, 0, 1, 1, 100, 100, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(9, 9, 9, 9));

    getContentPane().validate();
}

From source file:org.executequery.gui.ExecuteProcedurePanel.java

private void init() throws Exception {

    tableModel = new ParameterTableModel();
    table = new DefaultTable(tableModel);
    table.getTableHeader().setReorderingAllowed(false);
    table.setCellSelectionEnabled(true);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(false);

    connectionsCombo = WidgetFactory.createComboBox();
    schemaCombo = WidgetFactory.createComboBox();

    combosGroup = new TableSelectionCombosGroup(connectionsCombo, schemaCombo, null);
    combosGroup.addItemSelectionListener(this);

    objectTypeCombo = WidgetFactory.createComboBox(createAvailableObjectTypes());
    objectTypeCombo.setToolTipText("Select the database object type");
    objectTypeCombo.addItemListener(this);

    proceduresModel = new DynamicComboBoxModel();
    procedureCombo = WidgetFactory.createComboBox(proceduresModel);
    procedureCombo.setActionCommand("procedureSelectionChanged");
    procedureCombo.setToolTipText("Select the database object name");
    procedureCombo.addActionListener(this);

    JPanel base = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 7, 5, 8);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy++;//from  w w w.j ava 2s  . c  om
    base.add(new JLabel("Connection:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.insets.left = 0;
    base.add(connectionsCombo, gbc);
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridy++;
    gbc.insets.left = 7;
    gbc.insets.top = 0;
    base.add(new JLabel("Schema:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.insets.left = 0;
    base.add(schemaCombo, gbc);
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridy++;
    gbc.insets.left = 7;
    gbc.insets.top = 0;
    base.add(new JLabel("Object Type:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.insets.left = 0;
    base.add(objectTypeCombo, gbc);
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridy++;
    gbc.insets.left = 7;
    base.add(new JLabel("Object Name:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.insets.left = 0;
    base.add(procedureCombo, gbc);

    resultsPanel = new QueryEditorResultsPanel();
    JPanel resultsBase = new JPanel(new BorderLayout());
    resultsBase.add(resultsPanel, BorderLayout.CENTER);

    JSplitPane splitPane = new SplitPaneFactory().create(JSplitPane.VERTICAL_SPLIT, new JScrollPane(table),
            resultsBase);
    splitPane.setResizeWeight(0.5);
    splitPane.setDividerLocation(0.75);
    splitPane.setDividerSize(5);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weighty = 1.0;
    gbc.insets.left = 7;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    base.add(splitPane, gbc);

    JButton executeButton = ActionUtilities.createButton(this, "Execute", "execute");

    gbc.gridy++;
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets.top = 0;
    gbc.insets.bottom = 20;
    base.add(executeButton, gbc);

    base.setBorder(BorderFactory.createEtchedBorder());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 7, 5));

    add(base, BorderLayout.CENTER);

    EventMediator.registerListener(this);

    connectionSelectionMade();
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

protected void createNotValid() {
    GridBagConstraints c = new GridBagConstraints();
    URI licenseURI = LICENSE.getLicenseURI();
    JComponent comp;// w w  w . j ava2  s  .  c  o  m

    comp = new JLabel(getWarningIcon());
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(0, 0, 0, 5);
    DETAILS.add(comp, c);

    String invalidText = getInvalidString();
    if (licenseURI != null && allowRetryLink())
        invalidText += "  " + getRetryString();
    comp = newTextArea(invalidText);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(7, 0, 0, 0);
    DETAILS.add(comp, c);

    c.gridwidth = 1;
    c.gridheight = 2;
    c.weightx = 0;
    c.weighty = 0;
    DETAILS.add(javax.swing.Box.createGlue(), c);

    JButton button = new JButton(getVerifyString());
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LICENSE.verify(LicenseWindow.this);
            buildDetails();
        }
    });
    button.setVisible(licenseURI != null && allowVerifyLookup());
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.gridheight = 2;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 100);
    DETAILS.add(button, c);

    if (LICENSE.getLicenseDeed(URN) == null || !allowClaimedDeedLink()) {
        comp = new JLabel();
        comp.setVisible(false);
    } else {
        comp = new URLLabel(LICENSE.getLicenseDeed(URN), getClaimedDeedString());
    }
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(comp, c);

    if (licenseURI == null || !allowVerificationLink()) {
        comp = new JLabel();
        comp.setVisible(false);
    } else {
        comp = new URLLabel(licenseURI, getVerificationString());
    }
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(comp, c);
}

From source file:org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {

        // private boolean isCompteValid = false;
        private ValidState compteNumeroValidState = ValidState.getTrueInstance();
        private JUniqueTextField textNumero = new JUniqueTextField(7);

        @Override/*from w  w  w. j av  a  2 s. c  o  m*/
        public void update() {
            final int id = getSelectedID();
            super.update();
            final DBSystemRoot sysRoot = getTable().getDBSystemRoot();
            final SQLTable ecrT = sysRoot.getGraph().findReferentTable(getTable(), "ECRITURE");
            final UpdateBuilder updateBuilder = new UpdateBuilder(ecrT);
            updateBuilder.addForwardVirtualJoin(getTable(), "ID_COMPTE_PCE");
            updateBuilder.setFromVirtualJoinField("COMPTE_NUMERO", getTable().getAlias(), "NUMERO");
            updateBuilder.setFromVirtualJoinField("COMPTE_NOM", getTable().getAlias(), "NOM");
            updateBuilder.setWhere(new Where(ecrT.getField("ID_COMPTE_PCE"), "=", id));
            sysRoot.getDataSource().execute(updateBuilder.asString());
        }

        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();

            // Numero
            JLabel labelNumero = new JLabel("Numro ");

            this.add(labelNumero, c);

            c.gridx++;
            c.weightx = 0;
            c.weightx = 0.5;
            this.add(this.textNumero, c);
            this.textNumero.getTextField().getDocument().addDocumentListener(new SimpleDocumentListener() {

                @Override
                public void update(DocumentEvent e) {

                    // On verifie que le numero est correct
                    compteNumeroValidState = getCompteNumeroValidState(textNumero.getText());

                    fireValidChange();
                }
            });

            /*
             * textNumero.addKeyListener(new KeyAdapter(){
             * 
             * public void keyPressed(KeyEvent e) { } });
             */

            // Libell
            JLabel labelNom = new JLabel("Libell ");
            c.gridx++;
            c.weightx = 0;
            this.add(labelNom, c);

            JTextField textNom = new JTextField(30);
            c.gridx++;
            c.weightx = 1;
            this.add(textNom, c);

            // c.gridy++;
            c.gridx++;
            c.weightx = 0;
            JCheckBox checkRacine = new JCheckBox("Racine");
            this.add(checkRacine, c);

            // Infos
            JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
            c.gridy++;
            c.gridx = 0;
            c.weightx = 0;
            this.add(labelInfos, c);

            ITextArea textInfos = new ITextArea();
            c.gridx++;
            c.weightx = 1;
            c.weighty = 1;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridheight = GridBagConstraints.REMAINDER;
            c.fill = GridBagConstraints.BOTH;
            this.add(textInfos, c);

            this.addRequiredSQLObject(this.textNumero, "NUMERO");
            this.addRequiredSQLObject(textNom, "NOM");
            this.addSQLObject(textInfos, "INFOS");
            this.addSQLObject(checkRacine, "RACINE");
        }

        @Override
        public void select(SQLRowAccessor r) {
            super.select(r);
            if (r != null) {
                this.textNumero.setIdSelected(r.getID());
            }
        }

        @Override
        public synchronized ValidState getValidState() {
            return super.getValidState().and(this.compteNumeroValidState);
        }
    };
}

From source file:com.fisher.mainFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - nick xu
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    scrollPaneLogArea = new JScrollPane();
    logArea = new JTextArea();
    buttonBar = new JPanel();
    startButton = new JButton();
    stopButton = new JButton();

    //======== this ========
    setTitle("Fish Transform Trading");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//from  w ww.  j av  a  2  s  .com
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setPreferredSize(new Dimension(758, 900));

        // JFormDesigner evaluation mark
        dialogPane.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                        "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                        javax.swing.border.TitledBorder.BOTTOM,
                        new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                dialogPane.getBorder()));
        dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {

            //======== scrollPaneLogArea ========
            {
                scrollPaneLogArea.setViewportView(logArea);
            }

            GroupLayout contentPanelLayout = new GroupLayout(contentPanel);
            contentPanel.setLayout(contentPanelLayout);
            contentPanelLayout.setHorizontalGroup(contentPanelLayout.createParallelGroup()
                    .addComponent(scrollPaneLogArea, GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE));
            contentPanelLayout
                    .setVerticalGroup(contentPanelLayout.createParallelGroup()
                            .addGroup(contentPanelLayout
                                    .createSequentialGroup().addComponent(scrollPaneLogArea,
                                            GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 476, Short.MAX_VALUE)));
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);

        //======== buttonBar ========
        {
            buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
            buttonBar.setLayout(new GridBagLayout());
            ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 85, 80 };
            ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0, 0.0 };

            //---- startButton ----
            startButton.setText("Start");
            startButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    startButtonActionPerformed(e);
                }
            });
            buttonBar.add(startButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));

            //---- stopButton ----
            stopButton.setText("Stop");
            stopButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    stopButtonActionPerformed(e);
                }
            });
            buttonBar.add(stopButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

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

/**
 * This method initializes jPanelValue   
 *    /*from w  ww.j a v a2s  .co m*/
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelValue() {
    if (jPanelValue == null) {

        jPanelValue = new JPanel();
        jPanelValue.setLayout(new GridBagLayout());
        jPanelValue.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelValue.setPreferredSize(new Dimension(400, 200));

        // Default Report Location

        jLabelDefaultReportLocation = new JLabel();
        jLabelDefaultReportLocation.setText("Default Report Location:");
        jLabelDefaultReportLocation.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelDefaultReportLocation = new GridBagConstraints();
        gridBagConstraintsjLabelDefaultReportLocation.gridx = 0;
        gridBagConstraintsjLabelDefaultReportLocation.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelDefaultReportLocation.insets = new Insets(5, 0, 0, 0);
        gridBagConstraintsjLabelDefaultReportLocation.gridy = 1;

        GridBagConstraints gridBagConstraintsjpanelDefaultReportLocation = new GridBagConstraints();
        gridBagConstraintsjpanelDefaultReportLocation.fill = GridBagConstraints.BOTH;
        gridBagConstraintsjpanelDefaultReportLocation.gridy = 1;
        gridBagConstraintsjpanelDefaultReportLocation.weightx = 1.0;
        gridBagConstraintsjpanelDefaultReportLocation.insets = new Insets(10, 5, 5, 15);
        gridBagConstraintsjpanelDefaultReportLocation.gridx = 1;

        // reciprocal license

        jLabelReciprocalLicense = new JLabel();
        jLabelReciprocalLicense.setText("Reciprocal License (RED):");
        jLabelReciprocalLicense.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelReciprocalLicense = new GridBagConstraints();
        gridBagConstraintsjLabelReciprocalLicense.gridx = 0;
        gridBagConstraintsjLabelReciprocalLicense.insets = new Insets(0, 15, 0, 0);
        gridBagConstraintsjLabelReciprocalLicense.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelReciprocalLicense.gridy = 2;
        jPanelValue.add(jLabelDefaultReportLocation, gridBagConstraintsjLabelDefaultReportLocation);
        jPanelValue.add(getJPanelDefaultReportLocation(), gridBagConstraintsjpanelDefaultReportLocation);
        jPanelValue.add(jLabelReciprocalLicense, gridBagConstraintsjLabelReciprocalLicense);

        GridBagConstraints gridBagConstraintsgetJTextFieldReciprocalLicense = new GridBagConstraints();
        gridBagConstraintsgetJTextFieldReciprocalLicense.gridx = 1;
        gridBagConstraintsgetJTextFieldReciprocalLicense.weightx = 1.0;
        gridBagConstraintsgetJTextFieldReciprocalLicense.fill = GridBagConstraints.BOTH;
        gridBagConstraintsgetJTextFieldReciprocalLicense.insets = new Insets(5, 5, 5, 15);
        gridBagConstraintsgetJTextFieldReciprocalLicense.gridy = 2;
        jPanelValue.add(getJTextFieldReciprocalLicense(), gridBagConstraintsgetJTextFieldReciprocalLicense);

        // major license

        jLabelMajorLicense = new JLabel();
        jLabelMajorLicense.setText("Major License (ORANGE):");
        jLabelMajorLicense.setHorizontalAlignment(SwingConstants.RIGHT);

        GridBagConstraints gridBagConstraintsjLabelMajorLicense = new GridBagConstraints();
        gridBagConstraintsjLabelMajorLicense.gridx = 0;
        gridBagConstraintsjLabelMajorLicense.insets = new Insets(0, 15, 0, 0);
        gridBagConstraintsjLabelMajorLicense.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsjLabelMajorLicense.gridy = 3;
        jPanelValue.add(jLabelMajorLicense, gridBagConstraintsjLabelMajorLicense);

        GridBagConstraints gridBagConstraintsgetJTextFieldMajorLicense = new GridBagConstraints();
        gridBagConstraintsgetJTextFieldMajorLicense.gridx = 1;
        gridBagConstraintsgetJTextFieldMajorLicense.weightx = 1.0;
        gridBagConstraintsgetJTextFieldMajorLicense.fill = GridBagConstraints.BOTH;
        gridBagConstraintsgetJTextFieldMajorLicense.insets = new Insets(5, 5, 5, 15);
        gridBagConstraintsgetJTextFieldMajorLicense.gridy = 3;
        jPanelValue.add(getJTextFieldMajorLicense(), gridBagConstraintsgetJTextFieldMajorLicense);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.weighty = 1.0;
        gridBagConstraints3.weightx = 0.0;
        gridBagConstraints3.gridy = 4;
        JLabel jLabelEmpty = new JLabel();
        jLabelEmpty.setText("");
        jPanelValue.add(jLabelEmpty, gridBagConstraints3);
    }
    return jPanelValue;
}

From source file:mekhq.gui.FinancesTab.java

@Override
public void initTab() {
    resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$

    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());
    ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT);
    ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES);

    financeModel = new FinanceTableModel();
    financeTable = new JTable(financeModel);
    financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel));
    financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumn column = null;/*from w w  w . j av  a 2s.  c  o  m*/
    for (int i = 0; i < FinanceTableModel.N_COL; i++) {
        column = financeTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(financeModel.getColumnWidth(i));
        column.setCellRenderer(financeModel.getRenderer());
    }
    financeTable.setIntercellSpacing(new Dimension(0, 0));
    financeTable.setShowGrid(false);

    loanModel = new LoanTableModel();
    loanTable = new JTable(loanModel);
    loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel));
    loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    column = null;
    for (int i = 0; i < LoanTableModel.N_COL; i++) {
        column = loanTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(loanModel.getColumnWidth(i));
        column.setCellRenderer(loanModel.getRenderer());
    }
    loanTable.setIntercellSpacing(new Dimension(0, 0));
    loanTable.setShowGrid(false);
    JScrollPane scrollLoanTable = new JScrollPane(loanTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    JPanel panBalance = new JPanel(new GridBagLayout());
    panBalance.add(new JScrollPane(financeTable), gridBagConstraints);
    panBalance.setMinimumSize(new java.awt.Dimension(350, 100));
    panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet"));
    JPanel panLoan = new JPanel(new GridBagLayout());
    panLoan.add(scrollLoanTable, gridBagConstraints);

    JTabbedPane financeTab = new JTabbedPane();
    financeTab.setMinimumSize(new java.awt.Dimension(450, 300));
    financeTab.setPreferredSize(new java.awt.Dimension(450, 300));

    JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab);
    splitFinances.setOneTouchExpandable(true);
    splitFinances.setContinuousLayout(true);
    splitFinances.setResizeWeight(1.0);
    splitFinances.setName("splitFinances");

    financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan);
    financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel);
    financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(splitFinances, gridBagConstraints);

    JPanel panelFinanceRight = new JPanel(new BorderLayout());

    JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2));
    btnAddFunds = new JButton("Add Funds (GM)");
    btnAddFunds.addActionListener(ev -> addFundsActionPerformed());
    btnAddFunds.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnAddFunds);
    JButton btnGetLoan = new JButton("Get Loan");
    btnGetLoan.addActionListener(e -> showNewLoanDialog());
    pnlFinanceBtns.add(btnGetLoan);

    btnManageAssets = new JButton("Manage Assets (GM)");
    btnManageAssets.addActionListener(e -> manageAssets());
    btnManageAssets.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnManageAssets);

    panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH);

    areaNetWorth = new JTextArea();
    areaNetWorth.setLineWrap(true);
    areaNetWorth.setWrapStyleWord(true);
    areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12));
    areaNetWorth.setText(getCampaign().getFinancialReport());
    areaNetWorth.setEditable(false);

    JScrollPane descriptionScroll = new JScrollPane(areaNetWorth);
    panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER);
    areaNetWorth.setCaretPosition(0);
    descriptionScroll.setMinimumSize(new Dimension(300, 200));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    add(panelFinanceRight, gridBagConstraints);
}

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

protected void setupGUI() {
    // A scroll pane containing one labelled checkbox per component,
    // and a "run selected components" button below.
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridC = new GridBagConstraints();
    getContentPane().setLayout(gridBagLayout);

    JPanel checkboxPane = new JPanel();
    checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS));
    //checkboxPane.setPreferredSize(new Dimension(300, 300));
    int compIndex = 0;
    for (int j = 0; j < groups2Comps.length; j++) {
        String[] nextGroup = groups2Comps[j];
        JPanel groupPane = new JPanel();
        groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS));
        groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]),
                BorderFactory.createEmptyBorder(1, 1, 1, 1)));
        for (int i = 1; i < nextGroup.length; i++) {
            JButton configButton = new JButton();
            Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure");
            configButton.setIcon(configIcon);
            configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight()));
            configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i]));
            configButton.setBorderPainted(false);
            //System.out.println("Adding checkbox for "+components[i].getClass().getName());
            checkboxes[compIndex] = new JCheckBox(nextGroup[i]);
            checkboxes[compIndex].setFocusable(true);
            //checkboxes[i].setPreferredSize(new Dimension(200, 30));
            JPanel line = new JPanel();
            line.setLayout(new BorderLayout(5, 0));
            line.add(configButton, BorderLayout.WEST);
            line.add(checkboxes[compIndex], BorderLayout.CENTER);
            groupPane.add(line);//from w  w  w.j  a v  a  2 s  .c o m
            compIndex++;
        }
        checkboxPane.add(groupPane);
    }
    gridC.gridx = 0;
    gridC.gridy = 0;
    gridC.fill = GridBagConstraints.BOTH;
    JScrollPane scrollPane = new JScrollPane(checkboxPane);
    scrollPane.setPreferredSize(new Dimension(450, 300));
    gridBagLayout.setConstraints(scrollPane, gridC);
    getContentPane().add(scrollPane);

    JButton helpButton = new JButton("Help");
    helpButton.setMnemonic(KeyEvent.VK_H);
    helpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            displayHelpGUI();
        }
    });
    JButton settingsButton = new JButton("Settings");
    settingsButton.setMnemonic(KeyEvent.VK_S);
    settingsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            currentComponent = "Global properties";
            displaySettingsGUI();
        }
    });
    runButton = new JButton("Run");
    runButton.setMnemonic(KeyEvent.VK_R);
    runButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            runSelectedComponents();
        }
    });

    JButton quitAndSaveButton = new JButton("Quit");
    quitAndSaveButton.setMnemonic(KeyEvent.VK_Q);
    quitAndSaveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });

    gridC.gridy = 1;
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
    //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(runButton);
    //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(helpButton);
    //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(settingsButton);
    //buttonPanel.add(Box.createHorizontalGlue());
    //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT);
    buttonPanel.add(quitAndSaveButton);
    gridBagLayout.setConstraints(buttonPanel, gridC);
    getContentPane().add(buttonPanel);

    //getContentPane().setPreferredSize(new Dimension(300, 300));
    // End program when closing window:
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });
}