Example usage for java.awt GridBagConstraints EAST

List of usage examples for java.awt GridBagConstraints EAST

Introduction

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

Prototype

int EAST

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

Click Source Link

Document

Put the component on the right side of its display area, centered vertically.

Usage

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;/*from w ww. j a v a 2s .c  om*/
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java

/**
 * Sets the specified GridBagConstraints with the specified grid y coordinate and:<br>
 * <br>//from  w  w  w.jav  a  2s .  c  o m
 * grid x = 0 <br>
 * grid width = 1 <br>
 * weight x = 1 <br>
 * insets = LABEL_INSETS <br>
 * fill = GridBagConstraints.NONE <br>
 * anchor = GridBagConstraints.EAST
 * 
 * @param gbc
 *           the constraints to set
 * @param gridy
 *           the grid y coordinate
 */
private void setLabelConstraints(GridBagConstraints gbc, int gridy) {
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 0;
    gbc.insets = LABEL_INSETS;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
}

From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java

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

    // Numero du commande
    c.gridx = 0;//from w  w  w. j a  v a  2 s. c  o m
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Fournisseur
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fourn, c);

    if (!getTable().getFieldsName().contains("LIVRER")) {
        // Commande en cours
        JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
        c.gridx = 2;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = GridBagConstraints.REMAINDER;
        this.add(boxEnCours, c);
        c.gridwidth = 1;
        this.addRequiredSQLObject(boxEnCours, "EN_COURS");
    }

    // Fournisseur
    if (getTable().contains("ID_CONTACT_FOURNISSEUR")) {
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        final ElementComboBox boxContactFournisseur = new ElementComboBox();
        final SQLElement contactElement = Configuration.getInstance().getDirectory()
                .getElement("CONTACT_FOURNISSEUR");
        boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
        this.add(boxContactFournisseur, c);
        this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);

        fourn.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent arg0) {
                // TODO Raccord de mthode auto-gnr
                if (fourn.getSelectedRow() != null) {
                    boxContactFournisseur.getRequest()
                            .setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=",
                                    fourn.getSelectedRow().getID()));
                } else {
                    boxContactFournisseur.getRequest().setWhere(null);
                }
            }
        });
    }
    // Adresse de livraison
    if (getTable().getFieldsName().contains("ID_ADRESSE")) {
        if (getTable().getFieldsName().contains("LIVRAISON_F")) {
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;
            this.add(new JLabel(getLabelFor("ID_ADRESSE")), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            // c.gridy++;
            this.addView("ID_ADRESSE");
            final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            if (getTable().getFieldsName().contains("LIVRAISON_F")) {
                final JCheckBox boxLivr = new JCheckBox("Livr par le fournisseur");
                this.add(boxLivr, c);
                this.addSQLObject(boxLivr, "LIVRAISON_F");
                boxLivr.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if (boxLivr.isSelected() && !comp.isCreated()) {
                            comp.setCreated(true);
                            if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) {

                                SQLRowValues rowVals = getLivraisonAdr(
                                        ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE")
                                                .getComp()).getSelectedRow());

                                comp.setValue(rowVals);
                            }

                        } else {
                            if (!boxLivr.isSelected()) {
                                comp.setCreated(false);
                            }
                        }
                    }
                });
            }

            c.gridy++;
            this.add(comp, c);
            this.add(this.getView("ID_ADRESSE").getComp(), c);
        } else {

            c.gridy++;
            c.gridx = 0;
            this.add(new JLabel("Livraison"), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.add(boxLivrClient, c);
            c.gridwidth = 1;

            final GridBagConstraints cAdr = new DefaultGridBagConstraints();

            panelAdrSpec.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), cAdr);
            final ElementComboBox boxClient = new ElementComboBox(true);
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxClient, cAdr);
            this.addView(boxClient, "ID_CLIENT");

            cAdr.gridy++;
            cAdr.weightx = 0;
            cAdr.gridx = 0;
            panelAdrSpec.add(new JLabel("Adresse", SwingConstants.RIGHT), cAdr);
            final SQLRequestComboBox boxAdr = new SQLRequestComboBox(true);
            boxAdr.uiInit(Configuration.getInstance().getDirectory().getElement(getTable().getTable("ADRESSE"))
                    .getComboRequest(true));
            boxClient.addModelListener("wantedID", new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (boxClient.getSelectedRow() != null && !boxClient.getSelectedRow().isUndefined()) {
                        Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=",
                                boxClient.getSelectedRow().getID());
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_F")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_L")));
                        boxAdr.getRequest().setWhere(w);
                    } else {
                        boxAdr.getRequest().setWhere(null);
                    }
                }
            });
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxAdr, cAdr);

            cAdr.gridx = 0;
            cAdr.gridy++;
            cAdr.weightx = 0;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(new JLabel(getLabelFor("ID_ADRESSE")), cAdr);
            }
            cAdr.gridx++;
            cAdr.gridwidth = GridBagConstraints.REMAINDER;
            this.addView("ID_ADRESSE");
            compAdr = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            cAdr.gridy++;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(compAdr, cAdr);
            }
            boxAdr.addValueListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    SQLRow row = boxAdr.getSelectedRow();
                    if (row != null && !row.isUndefined()) {
                        compAdr.setCreated(true);
                        SQLRowValues asRowValues = new SQLRowValues(row.asRowValues());
                        compAdr.setValue(asRowValues);
                    }
                }
            });

            c.gridy++;
            c.gridx = 0;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            this.add(panelAdrSpec, c);
            c.gridwidth = 1;
            c.weightx = 0;

            boxLivrClient.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    panelAdrSpec.setVisible(boxLivrClient.isSelected());

                    if (!boxLivrClient.isSelected()) {
                        boxClient.setValue((Integer) null);
                        boxAdr.setValue((Integer) null);
                        compAdr.setCreated(false);
                    }
                }
            });
            panelAdrSpec.setVisible(false);
        }
    }
    c.gridwidth = 1;

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    final ElementComboBox boxDevise = new ElementComboBox();
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {
        // Devise
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.NONE;
        this.add(boxDevise, c);
        this.addView(boxDevise, "ID_DEVISE");
    }

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.EAST;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);

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

    String field;
    field = "ID_COMMERCIAL";
    // Commercial
    c.weightx = 0;
    c.gridx++;
    this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);

    ElementComboBox commSel = new ElementComboBox(false, 25);
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    this.add(commSel, c);
    addRequiredSQLObject(commSel, field);

    // Table d'lment
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 1;
    c.gridwidth = 4;
    this.add(this.table, c);
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {

        boxDevise.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                table.setDevise(boxDevise.getSelectedRow());

            }
        });
    }

    this.fourn.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            table.setFournisseur(fourn.getSelectedRow());
        }
    });
    // Bottom
    c.gridy++;
    c.weighty = 0;
    this.add(getBottomPanel(), c);

    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;

    JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panelOO.add(this.checkImpression, c);
    panelOO.add(this.checkVisu, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(panelOO, c);

    addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
    addSQLObject(textNom, "NOM");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");

    this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));

    // radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE);
    // this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() {
    // public void mousePressed(MouseEvent e) {
    //
    // if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
    // numeroUniqueDevis.setText(NumerotationAutoSQLElement.getNextNumeroDevis());
    // }
    // }
    // });

    DefaultGridBagConstraints.lockMinimumSize(this.fourn);
    DefaultGridBagConstraints.lockMinimumSize(commSel);
}

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

/**
 * This method initializes jPanelProjectList   
 *    /*from   w  w  w .  j  av  a2 s.com*/
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelProjectList() {
    if (jPanelProjectList == null) {
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.anchor = GridBagConstraints.EAST;
        gridBagConstraints8.weightx = 0.1;
        gridBagConstraints8.insets = new Insets(0, 0, 0, 10);
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = GridBagConstraints.CENTER;
        gridBagConstraints2.insets = new Insets(0, 0, 0, 10);
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.insets = new Insets(10, 10, 10, 10);
        gridBagConstraints.gridx = 0;
        jPanelProjectList = new JPanel();
        jPanelProjectList.setLayout(new GridBagLayout());
        jPanelProjectList.setBorder(BorderFactory.createTitledBorder(null, "Project",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelProjectList.add(getJButtonAdd(), gridBagConstraints8);
        jPanelProjectList.add(getJButtonCreate(), gridBagConstraints2);
        jPanelProjectList.add(getJScrollPanePjtList(), gridBagConstraints);
    }
    return jPanelProjectList;
}

From source file:org.esa.snap.rcp.spectrum.SpectrumTopComponent.java

private void initUI() {
    final JFreeChart chart = ChartFactory.createXYLineChart(Bundle.CTL_SpectrumTopComponent_Name(),
            "Wavelength (nm)", "", null, PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().getRangeAxis().addChangeListener(axisChangeEvent -> {
        if (!isCodeInducedAxisChange) {
            rangeAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
        }// w  w  w.  j ava 2  s.  c  o m
    });
    chart.getXYPlot().getDomainAxis().addChangeListener(axisChangeEvent -> {
        if (!isCodeInducedAxisChange) {
            domainAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
        }
    });
    chart.getXYPlot().getRangeAxis().setAutoRange(false);
    rangeAxisAdjustmentIsFrozen = false;
    chart.getXYPlot().getDomainAxis().setAutoRange(false);
    domainAxisAdjustmentIsFrozen = false;
    chartPanel = new ChartPanel(chart);
    chartHandler = new ChartHandler(chart);
    final XYPlotMarker plotMarker = new XYPlotMarker(chartPanel, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            //do nothing
        }

        @Override
        public void pointDeselected() {
            //do nothing
        }
    });

    filterButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Filter24.gif"), false);
    filterButton.setName("filterButton");
    filterButton.setEnabled(false);
    filterButton.addActionListener(e -> {
        selectSpectralBands();
        recreateChart();
    });

    showSpectrumForCursorButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showSpectrumForCursorButton.addActionListener(e -> recreateChart());
    showSpectrumForCursorButton.setName("showSpectrumForCursorButton");
    showSpectrumForCursorButton.setSelected(true);
    showSpectrumForCursorButton.setToolTipText("Show spectrum at cursor position.");

    showSpectraForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showSpectraForSelectedPinsButton.addActionListener(e -> {
        if (isShowingSpectraForAllPins()) {
            showSpectraForAllPinsButton.setSelected(false);
        } else if (!isShowingSpectraForSelectedPins()) {
            plotMarker.setInvisible();
        }
        recreateChart();
    });
    showSpectraForSelectedPinsButton.setName("showSpectraForSelectedPinsButton");
    showSpectraForSelectedPinsButton.setToolTipText("Show spectra for selected pins.");

    showSpectraForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showSpectraForAllPinsButton.addActionListener(e -> {
        if (isShowingSpectraForSelectedPins()) {
            showSpectraForSelectedPinsButton.setSelected(false);
        } else if (!isShowingSpectraForAllPins()) {
            plotMarker.setInvisible();
        }
        recreateChart();
    });
    showSpectraForAllPinsButton.setName("showSpectraForAllPinsButton");
    showSpectraForAllPinsButton.setToolTipText("Show spectra for all pins.");

    showGridButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SpectrumGrid24.gif"), true);
    showGridButton.addActionListener(e -> chartHandler.setGridVisible(showGridButton.isSelected()));
    showGridButton.setName("showGridButton");
    showGridButton.setToolTipText("Show diagram grid.");

    AbstractButton exportSpectraButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportSpectraButton.addActionListener(new SpectraExportAction(this));
    exportSpectraButton.setToolTipText("Export spectra to text file.");
    exportSpectraButton.setName("exportSpectraButton");

    AbstractButton helpButton = ToolButtonFactory.createButton(new HelpAction(this), false);
    helpButton.setName("helpButton");
    helpButton.setToolTipText("Help.");

    final JPanel buttonPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets.top = 2;
    gbc.gridy = 0;
    buttonPane.add(filterButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectrumForCursorButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForSelectedPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForAllPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showGridButton, gbc);
    gbc.gridy++;
    buttonPane.add(exportSpectraButton, gbc);

    gbc.gridy++;
    gbc.insets.bottom = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1.0;
    gbc.gridwidth = 2;
    buttonPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.gridy = 10;
    gbc.anchor = GridBagConstraints.EAST;
    buttonPane.add(helpButton, gbc);

    chartPanel.setPreferredSize(new Dimension(300, 200));
    chartPanel.setBackground(Color.white);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(BevelBorder.LOWERED), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    chartPanel.addChartMouseListener(plotMarker);

    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(BorderLayout.CENTER, chartPanel);
    mainPane.add(BorderLayout.EAST, buttonPane);
    mainPane.setPreferredSize(new Dimension(320, 200));

    SnapApp.getDefault().getProductManager().addListener(new ProductManager.Listener() {
        @Override
        public void productAdded(ProductManager.Event event) {
            // ignored
        }

        @Override
        public void productRemoved(ProductManager.Event event) {
            final Product product = event.getProduct();
            if (getCurrentProduct() == product) {
                chartPanel.getChart().getXYPlot().setDataset(null);
                setCurrentView(null);
                setCurrentProduct(null);
            }
            if (currentView != null) {
                final RasterDataNode currentRaster = currentView.getRaster();
                if (rasterToSpectraMap.containsKey(currentRaster)) {
                    rasterToSpectraMap.remove(currentRaster);
                }
                if (rasterToSpectralBandsMap.containsKey(currentRaster)) {
                    rasterToSpectralBandsMap.remove(currentRaster);
                }
            }
            PlacemarkGroup pinGroup = product.getPinGroup();
            for (int i = 0; i < pinGroup.getNodeCount(); i++) {
                chartHandler.removePinInformation(pinGroup.get(i));
            }
        }
    });

    final ProductSceneView view = getSelectedProductSceneView();
    if (view != null) {
        productSceneViewSelected(view);
    }
    setDisplayName(Bundle.CTL_SpectrumTopComponent_Name());
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
    updateUIState();
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java

public JPanel getJPanelLicenseFolder() {
    if (jPanelLicenseFolder == null) {
        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
        gridBagConstraints13.anchor = GridBagConstraints.WEST;
        gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints13.insets = new Insets(0, 0, 5, 0);
        gridBagConstraints13.gridx = 1;//from  w  w w  .j  a  v a  2 s  . c om
        gridBagConstraints13.gridy = 0;
        gridBagConstraints13.gridwidth = 1;
        gridBagConstraints13.weightx = 1.0;

        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.insets = new Insets(0, 0, 5, 3);
        gridBagConstraints11.gridy = 0;

        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.anchor = GridBagConstraints.WEST;
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints4.gridx = -1;
        gridBagConstraints4.gridy = 1;
        gridBagConstraints4.gridwidth = 1;
        gridBagConstraints4.weightx = 0.0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.insets = new Insets(0, 0, 0, 3);
        gridBagConstraints2.gridx = -1;
        gridBagConstraints2.gridy = 1;
        gridBagConstraints2.ipadx = 0;
        gridBagConstraints2.weightx = 0.0;
        gridBagConstraints2.fill = GridBagConstraints.NONE;
        jPanelLicenseFolder = new JPanel();
        jPanelLicenseFolder.setLayout(new GridBagLayout());
        jPanelLicenseFolder.setPreferredSize(new Dimension(403, 66));
        jPanelLicenseFolder.add(jLabelLicenseForOpt1, gridBagConstraints2);
        jPanelLicenseFolder.add(getJComboLicenseNameForOpt1(), gridBagConstraints4);
        jPanelLicenseFolder.add(jLabelComponentForOpt1, gridBagConstraints11);
        jPanelLicenseFolder.add(getJComboBoxComponent(), gridBagConstraints13);
    }
    return jPanelLicenseFolder;
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private JPanel getMatcherPanel() {
    if (matcherPanel == null) {
        matcherPanel = new JPanel();
        matcherPanel.setLayout(new GridBagLayout());
        Color bgColor = matcherPanel.getBackground();
        matcherPanel.setBorder(new RoundedBorderPanel(bgColor));

        GridBagConstraints constraint = new GridBagConstraints();
        constraint.gridx = 0;/*w ww .j av a  2s  .  c o m*/
        constraint.gridy = 0;
        constraint.insets = new Insets(0, 0, 0, 0);
        constraint.anchor = GridBagConstraints.FIRST_LINE_START;
        constraint.weightx = 0.5;

        ignore = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.ignore"));
        match = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.match"));

        ButtonGroup groupBtn = new ButtonGroup();
        groupBtn.add(ignore);
        groupBtn.add(match);

        keep = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.keep"));
        alpha = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.alpha"));
        characters = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.characters"));
        charField = new JTextField(20);

        numeric = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.numeric"));
        lengthMin = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.min.length"));
        lengthMax = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.max.length"));
        lengthMinField = new JTextField(10);
        lengthMaxField = new JTextField(10);

        matcherPanel.add(ignore, constraint);

        constraint.gridy = 1;
        constraint.anchor = GridBagConstraints.WEST;
        matcherPanel.add(match, constraint);

        constraint.anchor = GridBagConstraints.EAST;

        enterBtn = new JButton(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.setName(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.addActionListener(this);
        matcherPanel.add(enterBtn, constraint);

        constraint.anchor = GridBagConstraints.WEST;
        constraint.gridy = 2;
        matcherPanel.add(keep, constraint);

        constraint.gridy = 3;
        matcherPanel.add(alpha, constraint);

        constraint.gridy = 4;
        JPanel panelChar = new JPanel(new FlowLayout());
        panelChar.add(characters);
        panelChar.add(charField);
        matcherPanel.add(panelChar, constraint);

        constraint.gridy = 5;
        matcherPanel.add(numeric, constraint);

        constraint.gridy = 6;
        JPanel panelNumericLength = new JPanel();
        panelNumericLength.setLayout(new BoxLayout(panelNumericLength, BoxLayout.Y_AXIS));
        JPanel panelMinLength = new JPanel(new FlowLayout());
        panelMinLength.add(lengthMin);
        panelMinLength.add(lengthMinField);
        panelNumericLength.add(panelMinLength);
        JPanel panelMaxLength = new JPanel(new FlowLayout());
        panelMaxLength.add(lengthMax);
        panelMaxLength.add(lengthMaxField);
        panelNumericLength.add(panelMaxLength);
        matcherPanel.add(panelNumericLength, constraint);

        constraint.weighty = 1;

        matcherPanel.add(new JPanel(), constraint);
    }
    return matcherPanel;
}

From source file:edu.harvard.mcz.imagecapture.LoginDialog.java

/**
 * This method initializes jPanelAdvanced   
 *    //from  w w  w  .  jav a  2  s  .  c om
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelAdvanced() {
    if (jPanelAdvanced == null) {
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.anchor = GridBagConstraints.WEST;
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.gridy = 1;
        gridBagConstraints3.weightx = 1.0;
        gridBagConstraints3.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.anchor = GridBagConstraints.EAST;
        gridBagConstraints4.gridy = 1;
        gridBagConstraints4.insets = new Insets(0, 15, 0, 0);
        gridBagConstraints4.gridx = 0;
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridx = 1;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridx = 0;
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.anchor = GridBagConstraints.WEST;
        gridBagConstraints10.gridx = 1;
        gridBagConstraints10.gridy = 3;
        gridBagConstraints10.weightx = 1.0;
        gridBagConstraints10.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
        gridBagConstraints14.anchor = GridBagConstraints.WEST;
        gridBagConstraints14.gridx = 1;
        gridBagConstraints14.gridy = 2;
        gridBagConstraints14.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.anchor = GridBagConstraints.EAST;
        gridBagConstraints9.gridy = 3;
        gridBagConstraints9.gridx = 0;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.gridx = 1;
        gridBagConstraints6.gridy = 2;
        gridBagConstraints6.weightx = 1.0;
        gridBagConstraints6.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.anchor = GridBagConstraints.EAST;
        gridBagConstraints5.gridy = 2;
        gridBagConstraints5.gridx = 0;
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.anchor = GridBagConstraints.WEST;
        gridBagConstraints8.gridx = 1;
        gridBagConstraints8.gridy = 5;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.fill = GridBagConstraints.BOTH;
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.anchor = GridBagConstraints.EAST;
        gridBagConstraints7.gridx = 0;
        gridBagConstraints7.gridy = 5;
        gridBagConstraints7.insets = new Insets(0, 5, 0, 0);
        jPanelAdvanced = new JPanel();
        jPanelAdvanced.setLayout(new GridBagLayout());
        jPanelAdvanced.add(jLabel3, gridBagConstraints7);
        jPanelAdvanced.add(getJTextFieldConnection(), gridBagConstraints8);
        jPanelAdvanced.add(jLabel2, gridBagConstraints5);
        jPanelAdvanced.add(getJTextFieldDriver(), gridBagConstraints6);
        jPanelAdvanced.add(jLabel4, gridBagConstraints9);
        jPanelAdvanced.add(getJTextFieldDialect(), gridBagConstraints10);
        jPanelAdvanced.add(jLabel, gridBagConstraints);
        jPanelAdvanced.add(getJTextFieldUsername(), gridBagConstraints1);
        jPanelAdvanced.add(jLabel1, gridBagConstraints4);
        jPanelAdvanced.add(getJPasswordFieldDB(), gridBagConstraints3);
    }
    return jPanelAdvanced;
}

From source file:org.openmrs.test.BaseContextSensitiveTest.java

/**
 * Utility method for obtaining username and password through Swing interface for tests. Any
 * tests extending the org.openmrs.BaseTest class may simply invoke this method by name.
 * Username and password are returned in a two-member String array. If the user aborts, null is
 * returned. <b> <em>Do not call for non-interactive tests, since this method will try to
 * render an interactive dialog box for authentication!</em></b>
 * /*from w w  w  .  j a va  2s .co  m*/
 * @param message string to display above username field
 * @return Two-member String array containing username and password, respectively, or
 *         <code>null</code> if user aborts dialog
 */
public static synchronized String[] askForUsernameAndPassword(String message) {

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {

    }

    if (message == null || "".equals(message))
        message = "Enter username/password to authenticate to OpenMRS...";

    JPanel panel = new JPanel(new GridBagLayout());
    JLabel usernameLabel = new JLabel("Username");
    usernameLabel.setFont(font);
    usernameField = new JTextField(20);
    usernameField.setFont(font);
    JLabel passwordLabel = new JLabel("Password");
    passwordLabel.setFont(font);
    JPasswordField passwordField = new JPasswordField(20);
    passwordField.setFont(font);
    panel.add(usernameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
    panel.add(usernameField, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    panel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
    panel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    frame = new JFrame();
    Window window = new Window(frame);
    frame.setVisible(true);
    frame.setTitle("JUnit Test Credentials");

    // We use a TimerTask to force focus on username, but still use
    // JOptionPane for model dialog
    TimerTask later = new TimerTask() {

        @Override
        public void run() {
            if (frame != null) {
                // bring the dialog's window to the front
                frame.toFront();
                usernameField.grabFocus();
            }
        }
    };
    // try setting focus half a second from now
    new Timer().schedule(later, 500);

    // attention grabber for those people that aren't as observant
    TimerTask laterStill = new TimerTask() {

        @Override
        public void run() {
            if (frame != null) {
                frame.toFront(); // bring the dialog's window to the
                // front
                usernameField.grabFocus();
            }
        }
    };
    // if the user hasn't done anything in 10 seconds, tell them the window
    // is there
    new Timer().schedule(laterStill, 10000);

    // show the dialog box
    int response = JOptionPane.showConfirmDialog(window, panel, message, JOptionPane.OK_CANCEL_OPTION);

    // clear out the window so the timer doesn't screw up
    laterStill.cancel();
    frame.setVisible(false);
    window.setVisible(false);
    frame = null;

    // response of 2 is the cancel button, response of -1 is the little red
    // X in the top right
    return (response == 2 || response == -1 ? null
            : new String[] { usernameField.getText(), String.valueOf(passwordField.getPassword()) });
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getIntervalo() {
    JPanel intervalo = new JPanel(new GridBagLayout());
    intervalo.setOpaque(false);//from   w  w  w . j  a  va2s . c o m
    intervalo.setBorder(new TitledBorder("Intervalo Temporal de Consulta"));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    intervalo.add(new JLabel("Fecha/Hora Inicial"), gbc);
    gbc.gridx++;
    calendarini = new JCalendarCombo();
    calendarini.addActionListener(actionListener);
    calendarini.addDateListener(dateListener);
    intervalo.add(calendarini, gbc);
    gbc.gridx++;
    final Calendar instance = Calendar.getInstance();
    instance.set(Calendar.HOUR, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    horaini = initializeSpinner(instance);
    intervalo.add(horaini, gbc);

    gbc.gridx = 0;
    gbc.gridy++;

    intervalo.add(new JLabel("Fecha/Hora Final"), gbc);
    gbc.gridx++;
    calendarfin = new JCalendarCombo();
    calendarfin.addActionListener(actionListener);
    calendarfin.addDateListener(dateListener);
    intervalo.add(calendarfin, gbc);
    gbc.gridx++;
    horafin = initializeSpinner(instance);
    intervalo.add(horafin, gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.EAST;
    soloUltimas = new JCheckBox();
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRecursos();
        }
    });
    soloUltimas.setOpaque(false);
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean enabled = !soloUltimas.isSelected();
            calendarini.setEnabled(enabled);
            calendarfin.setEnabled(enabled);
            horaini.setEnabled(enabled);
            horafin.setEnabled(enabled);
        }
    });
    intervalo.add(soloUltimas, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.WEST;
    intervalo.add(new JLabel("Consultar Slo Las ltimas Posiciones"), gbc);

    return intervalo;
}