Example usage for javax.swing JLabel setHorizontalAlignment

List of usage examples for javax.swing JLabel setHorizontalAlignment

Introduction

In this page you can find the example usage for javax.swing JLabel setHorizontalAlignment.

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The alignment of the label's content along the X axis.")
public void setHorizontalAlignment(int alignment) 

Source Link

Document

Sets the alignment of the label's contents along the X axis.

Usage

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;//  w w  w  .ja  va 2s  .  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:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java

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

    // Champ Module
    c.gridx = 0;/*w ww .  j a v a 2  s.  com*/
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

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

    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();
    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

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

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

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(date, c);
    // Reference
    c.gridy++;
    c.gridx = 0;
    final JLabel labelNom = new JLabel(getLabelFor("NOM"));
    labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNom, c);
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    DefaultGridBagConstraints.lockMinimumSize(this.textReference);
    this.add(this.textReference, c);
    // Fournisseur
    JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
    labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(labelFournisseur, c);

    this.fournisseur = new ElementComboBox();
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fournisseur, c);

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

    final ElementComboBox boxDevise = new ElementComboBox();
    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");

    // Element du bon
    this.tableBonItem = new BonReceptionItemTable();
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    this.fournisseur.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            tableBonItem.setFournisseur(fournisseur.getSelectedRow());
        }
    });

    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    if (b) {
        JPanel panelPoids = new JPanel(new GridBagLayout());
        GridBagConstraints c2 = new DefaultGridBagConstraints();
        c2.fill = GridBagConstraints.NONE;

        panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2);
        // Necessaire pour ne pas avoir de saut de layout
        DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal);
        this.textPoidsTotal.setEnabled(false);
        this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        this.textPoidsTotal.setDisabledTextColor(Color.BLACK);
        c2.gridx++;
        c2.weightx = 1;
        c2.fill = GridBagConstraints.HORIZONTAL;
        panelPoids.add(this.textPoidsTotal, c2);
        this.add(panelPoids, c);

    }

    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints cTotalPan = new DefaultGridBagConstraints();

    JPanel panelTotalHT = new JPanel();
    panelTotalHT.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    cTotalPan.anchor = GridBagConstraints.WEST;
    final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT"));
    panelTotalHT.add(labelTotalHT, cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    this.textTotalHT.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT);
    panelTotalHT.add(this.textTotalHT, cTotalPan);
    this.add(panelTotalHT, c);

    JPanel panelTotalTVA = new JPanel();
    panelTotalTVA.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA);
    panelTotalTVA.add(this.textTotalTVA, cTotalPan);
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotalTVA, c);

    JPanel panelTotalTTC = new JPanel();
    panelTotalTTC.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.gridwidth = GridBagConstraints.REMAINDER;
    cTotalPan.fill = GridBagConstraints.BOTH;
    cTotalPan.weightx = 1;
    panelTotalTTC.add(new JSeparator(), cTotalPan);
    cTotalPan.gridwidth = 1;
    cTotalPan.fill = GridBagConstraints.NONE;
    cTotalPan.weightx = 0;
    cTotalPan.gridy++;
    panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    this.textTotalTTC.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC);
    panelTotalTTC.add(this.textTotalTTC, cTotalPan);
    c.gridy++;
    // probleme de tremblement vertical
    this.add(panelTotalTTC, c);
    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final ITextArea textInfos = new ITextArea(4, 4);
    JScrollPane scrollPane = new JScrollPane(textInfos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    this.add(textInfos, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textReference, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR");

    this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class));

    // Listeners
    this.tableBonItem.getModel().addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {

            int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement());
            int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement());
            int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel()
                    .getColumnIndexForElement(
                            BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement());

            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT
                    || e.getColumn() == columnIndexTTC) {
                updateTotal();
            }
            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) {
                BonReceptionSQLComponent.this.textPoidsTotal.setText(String
                        .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000)
                                / 1000.0));
            }
        }
    });

    // Lock UI
    DefaultGridBagConstraints.lockMinimumSize(this.fournisseur);

}

From source file:org.openconcerto.task.TodoListPanel.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel label = (JLabel) this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);/*from w ww.  j av  a  2s.  com*/
    label.setIcon(this.icon);
    label.setBorder(BorderFactory.createEmptyBorder());
    label.setIconTextGap(0);
    label.setHorizontalTextPosition(0);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
}

From source file:org.ops4j.pax.idea.runner.forms.OsgiConfigEditorForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection HardCodedStringLiteral// www  .  ja v a 2s .c om
 */
private void $$$setupUI$$$() {
    m_mainPanel = new JPanel();
    m_mainPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1));
    m_mainPanel.add(panel1,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel2.setBorder(BorderFactory.createTitledBorder("Platform"));
    final JScrollPane scrollPane1 = new JScrollPane();
    panel2.add(scrollPane1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    m_platforms = new JList();
    scrollPane1.setViewportView(m_platforms);
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel3,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel3.setBorder(BorderFactory.createTitledBorder("Options"));
    m_startGui = new JCheckBox();
    m_startGui.setText("Start GUI");
    panel3.add(m_startGui,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    m_runClean = new JCheckBox();
    m_runClean.setText("Run Clean");
    panel3.add(m_runClean,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JScrollPane scrollPane2 = new JScrollPane();
    panel1.add(scrollPane2,
            new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    scrollPane2.setBorder(BorderFactory.createTitledBorder("System Properties"));
    m_systemProperties = new JTable();
    m_systemProperties.setEnabled(true);
    scrollPane2.setViewportView(m_systemProperties);
    final JPanel panel4 = new JPanel();
    panel4.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel4,
            new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel4.setBorder(BorderFactory.createTitledBorder("Proxy"));
    final JLabel label1 = new JLabel();
    label1.setText("Port:");
    panel4.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Username:");
    panel4.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Password:");
    panel4.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    m_proxyHost = new JTextField();
    panel4.add(m_proxyHost,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    m_proxyPort = new JTextField();
    panel4.add(m_proxyPort,
            new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    m_proxyUser = new JTextField();
    panel4.add(m_proxyUser,
            new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    m_proxyPass = new JPasswordField();
    panel4.add(m_proxyPass,
            new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JLabel label4 = new JLabel();
    label4.setHorizontalAlignment(10);
    label4.setHorizontalTextPosition(10);
    label4.setText("Host:");
    panel4.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel5 = new JPanel();
    panel5.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel5,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label5 = new JLabel();
    label5.setText("Working Dir:");
    panel5.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    m_workDir = new JTextField();
    panel5.add(m_workDir,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    m_selectDir = new JButton();
    m_selectDir.setText("...");
    panel5.add(m_selectDir,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel6 = new JPanel();
    panel6.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel6,
            new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label6 = new JLabel();
    label6.setText("VM Arguments:");
    panel6.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    m_vmArguments = new JTextField();
    panel6.add(m_vmArguments,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JPanel panel7 = new JPanel();
    panel7.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel7,
            new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final JLabel label7 = new JLabel();
    label7.setText("JDK:");
    panel7.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    m_jdk = new JTextField();
    m_jdk.setEditable(false);
    panel7.add(m_jdk,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JPanel panel8 = new JPanel();
    panel8.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
    m_mainPanel.add(panel8,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel8.setBorder(BorderFactory.createTitledBorder("Bundles"));
    final JPanel panel9 = new JPanel();
    panel9.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
    panel8.add(panel9,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    JButton add = new JButton();
    add.setText("Add...");
    panel9.add(add,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JScrollPane scrollPane3 = new JScrollPane();
    panel8.add(scrollPane3,
            new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    scrollPane3.setBorder(BorderFactory.createTitledBorder("Properties"));
    m_bundleProperties = new JTable();
    scrollPane3.setViewportView(m_bundleProperties);
    final JScrollPane scrollPane4 = new JScrollPane();
    panel8.add(scrollPane4,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    m_bundles = new JList();
    scrollPane4.setViewportView(m_bundles);
    final JPanel panel10 = new JPanel();
    panel10.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel8.add(panel10,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    panel10.setBorder(BorderFactory.createTitledBorder("Description"));
    m_description = new JTextArea();
    panel10.add(m_description,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null,
                    new Dimension(150, 50), null, 0, false));
}

From source file:org.p_vcd.ui.VcdDialog.java

public VcdDialog() {
    setSize(700, 450);// w w w . j a  v a 2  s  .  c  om
    setTitle("P-VCD - Video Copy Detection");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.currentStep = 1;

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new CardLayout(0, 0));
    {
        JPanel panel_Step1 = new JPanel();
        contentPanel.add(panel_Step1, "card_step1");
        panel_Step1.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 1 - Video Database (the \"known\")");
        panel_Step1.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel_1 = new JPanel();
        panel_Step1.add(panel_1, BorderLayout.CENTER);
        panel_1.setLayout(new MigLayout("", "[250px,grow][20px][250px,grow]", "[][][230px,grow][][][]"));

        JLabel lblNewLabel = new JLabel("Please select the video databases to search in:");
        panel_1.add(lblNewLabel, "cell 0 0");

        panel_1.add(lbl_refDbTitle, "cell 2 1");

        JScrollPane scrollPane_1 = new JScrollPane();
        panel_1.add(scrollPane_1, "cell 0 1 1 3,grow");
        panel_refDatabasesList.setBackground(Color.WHITE);

        scrollPane_1.setViewportView(panel_refDatabasesList);
        panel_refDatabasesList.setLayout(new MigLayout("gapy 10", "[200px]", "[][]"));

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBorder(null);
        panel_1.add(scrollPane, "cell 2 2,grow");

        scrollPane.setViewportView(lbl_refDbFiles);

        panel_1.add(lbl_refDbMetadata, "cell 2 3");

        JButton btnNewDatabase = new JButton("New database...");
        panel_1.add(btnNewDatabase, "cell 0 4");
        btnNewDatabase.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                newDatabaseButton();
            }
        });
    }
    {
        JPanel panel_Step2 = new JPanel();
        contentPanel.add(panel_Step2, "card_step2");
        panel_Step2.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 2 - Query (the \"unknown\")");
        panel_Step2.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Query",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_Step2.add(panel, BorderLayout.CENTER);
        panel.setLayout(
                new MigLayout("", "[160px][grow]", "[25px][grow,top][25px][grow,top][25px][grow,top][grow]"));

        ButtonGroup queryButtonGroup = new ButtonGroup();

        queryButtonGroup.add(radio_queryFile);
        radio_queryFile.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryFile, "cell 0 0");

        lbl_queryFile.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryFile.setSelected(true);
            }
        });
        panel.add(lbl_queryFile, "flowy,cell 1 0");

        JButton btnSelectFile = new JButton("Select File...");
        btnSelectFile.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                selectFileButton();
            }
        });
        panel.add(btnSelectFile, "cell 1 0");

        JLabel lblIumageOrVideo = new JLabel("Select an image or video in the local machine.");
        panel.add(lblIumageOrVideo, "cell 1 1");

        queryButtonGroup.add(radio_queryUrl);
        radio_queryUrl.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryUrl, "cell 0 2");

        txt_queryUrl.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.setText("http://");
        panel.add(txt_queryUrl, "flowy,cell 1 2");
        txt_queryUrl.setColumns(50);

        JLabel lblUrlToA = new JLabel(
                "<html>Enter the URL to download an image or video.<br>You can use a URL like: http://www.youtube.com/watch?v=... </html>");
        panel.add(lblUrlToA, "flowy,cell 1 3");

        queryButtonGroup.add(radio_queryDb);
        radio_queryDb.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryDb, "cell 0 4");

        comboBox_queryDb.setMaximumRowCount(12);
        comboBox_queryDb.setPreferredSize(new Dimension(100, 20));
        comboBox_queryDb.setMinimumSize(new Dimension(100, 20));
        comboBox_queryDb.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });
        comboBox_queryDb.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });

        panel.add(comboBox_queryDb, "flowx,cell 1 4");

        panel.add(lbl_queryDb, "cell 1 4");

        JLabel lblPleaseNopteThe = new JLabel("<html>A search is run for each video in the database.</html>");
        panel.add(lblPleaseNopteThe, "cell 1 5");

    }
    {
        JPanel panel_Step3 = new JPanel();
        contentPanel.add(panel_Step3, "card_step3");
        panel_Step3.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 3 - Search Options");
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        panel_Step3.add(lblTitle, BorderLayout.NORTH);

        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        panel_Step3.add(panel2, BorderLayout.CENTER);
        JPanel panel = new JPanel();
        panel2.add(panel);
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Basic Options",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setLayout(new MigLayout("gapy 5px", "[30px][101px]", "[][][][][][][20px]"));

        ButtonGroup buttonGroup = new ButtonGroup();

        buttonGroup.add(radio_searchByGlobal);
        radio_searchByGlobal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        radio_searchByGlobal.setSelected(true);
        panel.add(radio_searchByGlobal, "cell 0 0 2 1,alignx left,aligny top");

        JLabel lblNewLabel_2 = new JLabel(
                "Detects most of the copies that are visually alike to the original.");
        panel.add(lblNewLabel_2, "cell 1 1");

        JButton btnOptions = new JButton("Advanced Options...");
        btnOptions.setEnabled(false);
        panel.add(btnOptions, "cell 1 2");

        buttonGroup.add(radio_searchByLocal);
        radio_searchByLocal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_searchByLocal, "cell 0 4 2 1,alignx left,aligny top");

        JLabel lblNewLabel_3 = new JLabel(
                "Requires more resources (disk space, search time, memory) but can detect more copies.");
        panel.add(lblNewLabel_3, "cell 1 5");

        JButton btnOptions_1 = new JButton("Advanced Options...");
        btnOptions_1.setEnabled(false);
        panel.add(btnOptions_1, "cell 1 6");

    }
    {
        JPanel panel_Step4 = new JPanel();
        contentPanel.add(panel_Step4, "card_step4");
        panel_Step4.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 4 - Search");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step4.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step4.add(scrollPane, BorderLayout.CENTER);

        textConsole.setFont(new Font("Monospaced", Font.PLAIN, 11));
        textConsole.setForeground(Color.WHITE);
        textConsole.setBackground(Color.BLACK);
        textConsole.setEditable(false);
        textConsole.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        textConsole.setText(
                "Press 'Next' button to start the search...\nNote: Depending on the selected options, the search may take up to several hours.");
        scrollPane.setViewportView(textConsole);

        JPanel panel = new JPanel();
        panel_Step4.add(panel, BorderLayout.SOUTH);
        panel.setLayout(new GridLayout(0, 1, 0, 0));

        JSeparator separator = new JSeparator();
        separator.setPreferredSize(new Dimension(0, 1));
        panel.add(separator);
        progressBar.setStringPainted(true);
        progressBar.setPreferredSize(new Dimension(350, 20));
        panel.add(progressBar);

        lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
        lblProgress.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel.add(lblProgress);
    }
    {
        JPanel panel_Step5 = new JPanel();
        contentPanel.add(panel_Step5, "card_step5");
        panel_Step5.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 5 - Results");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step5.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step5.add(scrollPane, BorderLayout.CENTER);

        scrollPane.setViewportView(panelResults);
        panelResults.setLayout(new MigLayout("gapy 10, gapx 20",
                "[120px,center][150px,center,grow][150px,center,grow]", "[25px][]"));

    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton prevButton = new JButton("Previous");
            prevButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    previousButton();
                }
            });
            prevButton.setActionCommand("Previous");
            buttonPane.add(prevButton);
        }
        {
            JButton okButton = new JButton("Next");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    nextButton();
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelButton();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            closeWindow();
        }
    });
    updateDatabases(null);
}

From source file:org.spottedplaid.ui.Mainframe.java

/**
 * Create the frame.//from   ww w  . j a  va2  s .  c o m
 *
 * @param _Sqliteops the _ sqliteops
 * @param _Crypto the _ crypto
 */
public Mainframe(SQliteOps _Sqliteops, Crypto _Crypto) {

    l_sqliteops = _Sqliteops;
    l_crypto = _Crypto;

    setTitle("The Password Saver - Management");
    setResizable(false);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 982, 656);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });

    mnFile.add(mntmExit);

    JMenu mnTools = new JMenu("Tools");
    menuBar.add(mnTools);

    JMenuItem mntmChgpwd = new JMenuItem("Change Passphrase");
    mntmChgpwd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Changepwd changePwd = new Changepwd(l_crypto, l_sqliteops);
            changePwd.setVisible(true);
        }
    });

    mnTools.add(mntmChgpwd);

    JMenuItem mntmExpirationReport = new JMenuItem("Expiration Report");
    mntmExpirationReport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecExp = new DbRecord();
            dbRecExp.setType(Pwdtypes.S_EXP_RPT);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecExp);
            String[] sRecord = new String[3];
            String sData = "";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null && arrData.size() > 0) {
                try {
                    String sFilename = "ExpirationReport.txt";
                    File fileExpRpt = new File(sFilename);

                    BufferedWriter buffWriter = new BufferedWriter(new FileWriter(fileExpRpt));
                    buffWriter.write("URL/Application                Challenge            Expiration");
                    buffWriter.write("\n");
                    buffWriter.write("--------------------------------------------------------------");
                    buffWriter.write("\n");
                    for (int iCount = 0; iCount < arrData.size(); iCount++) {
                        sData = arrData.get(iCount);
                        System.out.println("DEBUG->sData [" + sData + "]");
                        StringTokenizer st = new StringTokenizer(sData, "|");
                        iElement = 0;
                        while (st.hasMoreTokens()) {
                            sRecord[iElement] = st.nextToken();
                            iElement++;
                        }

                        /// Define the padding for the output
                        int iPadValue1 = 35 - sRecord[0].length();
                        if (iPadValue1 < 0) {
                            iPadValue1 = 2;
                        }

                        int iPadValue2 = 55 - (35 + sRecord[1].length());
                        if (iPadValue2 < 0) {
                            iPadValue2 = 2;
                        }

                        iPadValue1 += sRecord[1].length();
                        iPadValue2 += sRecord[2].length();

                        buffWriter.write(sRecord[0] + StringUtils.leftPad(sRecord[1], iPadValue1)
                                + StringUtils.leftPad(sRecord[2], iPadValue2) + "\n");
                        buffWriter.write("\n");
                    }
                    buffWriter.close();

                    /// Opens WordPad on Windows systems.  This could be changed to use a property in order to work on a linux/unix/apple system
                    ProcessBuilder pb = new ProcessBuilder("write.exe", sFilename);
                    pb.start();
                } catch (IOException ie) {
                    System.out.println("Expiration Report IO Exception [" + ie.getMessage() + "]");
                    ie.printStackTrace();
                }

            } else {
                JOptionPane.showMessageDialog(null, "No expiring records found");
            }
        }
    });
    mnTools.add(mntmExpirationReport);

    JMenuItem mntmViewLogs = new JMenuItem("View Logs");
    mntmViewLogs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DbRecord dbRecLogs = new DbRecord();
            dbRecLogs.setType(Pwdtypes.S_LOG_TYPE);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecLogs);
            String[] sRecord = new String[3];
            String sData = "";
            String sTitle = "Display Data Changes";
            String sDisplay = "Date                  Log Message";
            sDisplay += "\n";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null) {
                for (int iCount = 0; iCount < arrData.size(); iCount++) {
                    sData = arrData.get(iCount);
                    System.out.println("DEBUG->sData [" + sData + "]");
                    StringTokenizer st = new StringTokenizer(sData, "|");
                    iElement = 0;
                    while (st.hasMoreTokens()) {
                        sRecord[iElement] = st.nextToken();
                        iElement++;
                    }
                    sDisplay += sRecord[2] + ":" + sRecord[1];
                    sDisplay += "\n";
                }

                if (arrData.size() > 0) {
                    JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
                }

            }
        }
    });

    mnTools.add(mntmViewLogs);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);

    JLabel lblThePasswordSaver = new JLabel("The Password Saver - Manage Passwords");
    lblThePasswordSaver.setFont(new Font("Arial", Font.BOLD, 16));
    lblThePasswordSaver.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel lblUrlapplication = new JLabel("URL/Application");

    jtxtApp = new JTextField();
    jtxtApp.setColumns(10);

    JLabel lblDescription = new JLabel("Description");

    jtxtDesc = new JTextField();
    jtxtDesc.setColumns(10);

    /// Button - Add button for clients/apps
    JButton btnAdd = new JButton("Add");
    btnAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyAppData(jtxtApp.getText().toString(), jtxtDesc.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "URL/Application and Description are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
                dbRec.setClientName(jtxtApp.getText().toString());
                dbRec.setClientDesc(jtxtDesc.getText().toString());
                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setClientId(l_iClientId);
                    addToTable();
                }
            }
        }
    });

    /// Buttons - Replace button for clients/apps
    btnReplace = new JButton("Replace");
    btnReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null, "Update record warning: Please select record to continue");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientId(iClientId);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            if (l_sqliteops.updateRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
            } else {
                int iRow = jtabApps.getSelectedRow();
                jtabApps.setValueAt(jtxtApp.getText().toString(), iRow, 1);
                jtabApps.setValueAt(jtxtDesc.getText().toString(), iRow, 2);

                clearFields();
            }
        }
    });

    btnReplace.setEnabled(false);

    /// Button - Delete button for clients/apps
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete record failed: Please select a record then click Delete");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType("clients");
            dbRec.setClientId(iClientId);
            dbRec.setDelCreds(0);

            if (chkDelAssoc.isSelected()) {
                dbRec.setDelCreds(1);
            }

            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Delete record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabApps.getModel();
                jtabModel.removeRow(jtabApps.getSelectedRow());
                if (chkDelAssoc.isSelected()) {
                    DefaultTableModel model = (DefaultTableModel) jtabCreds.getModel();
                    model.setRowCount(0);
                }
                clearFields();
            }
        }
    });
    btnDelete.setEnabled(false);

    /// Buttons - Search button for clients/apps
    btnSearch = new JButton("Search");
    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            loadTable(dbRec);
        }
    });

    btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearFields();
        }
    });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    /// Begin section for credentials challenges/responses - text fields and buttons
    JLabel lblChallenge = new JLabel("Challenge");

    JLabel lblResponse = new JLabel("Response");

    jtxtChlng = new JTextField();
    jtxtChlng.setColumns(10);

    jtxtRsp = new JTextField();
    jtxtRsp.setColumns(10);

    /// Buttons - Add button for credentials
    btnCredAdd = new JButton("Add");
    btnCredAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyCredData(jtxtChlng.getText().toString(),
                    jtxtRsp.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "Challenge and Response are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /// Set the modify date if the track days are > 0
                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    Calendar calNow = Calendar.getInstance();
                    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
                    int iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    String sValue = sdf.format(calNow.getTime());
                    dbRec.setModifyDate(sValue);
                }

                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setCredId(l_iClientId);
                    addToCredsTable();
                }
            }
        }
    });

    /// Button - Replace button for credentials
    btnCredReplace = new JButton("Replace");
    btnCredReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecLog = new DbRecord();
            int iDaysToAdd = 0;
            Calendar calNow = Calendar.getInstance();
            SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");

            String sCurDate = sdf1.format(calNow.getTime());
            String sValue = sDateModified;
            String sLogMsg = "";
            StringBuilder sbLogMsg = new StringBuilder(sLogMsg);

            if (dbRec.getType().equals(Pwdtypes.S_CREDS_TYPE) && (dbRec.getCredId() > 0)) {
                dbRec.setClientId(iClientId);
                dbRec.setCredId(iCredId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /** Check for changes and insert log if necessary */
                if (!sChallenge.equals(jtxtChlng.getText())) {
                    sbLogMsg.append("Application [" + jtxtApp.getText() + "], Challenge modified, old ["
                            + sChallenge + "], new [" + jtxtChlng.getText() + "]");
                }

                if (!sResponse.equals(jtxtRsp.getText())) {
                    if (sbLogMsg.toString().length() > 0) {
                        sbLogMsg.append(",");
                    } else {
                        sbLogMsg.append("Application [" + jtxtApp.getText() + "],");
                    }
                    sbLogMsg.append("Response modified, old [" + sResponse + "]");
                }

                if (sbLogMsg.toString().length() > 0) {
                    dbRecLog.setType(Pwdtypes.S_LOG_TYPE);
                    dbRecLog.setLog(sbLogMsg.toString());
                    dbRecLog.setModifyDate(sCurDate);
                    if (l_sqliteops.insertRecord(dbRecLog) < 0) {
                        JOptionPane.showMessageDialog(null,
                                "Insert log record failed [" + dbRecLog.getResult() + "]");
                    }
                }

                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    sValue = sdf1.format(calNow.getTime());

                    System.out.println("DEBUG->Date (sValue) [" + sValue + "]");
                    dbRec.setModifyDate(sValue);
                }
                /// Update the record
                if (l_sqliteops.updateRecord(dbRec) < 0) {
                    JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
                } else {
                    int iRow = jtabCreds.getSelectedRow();
                    jtabCreds.setValueAt(jtxtChlng.getText().toString(), iRow, 1);
                    jtabCreds.setValueAt(l_crypto.encrypt(jtxtRsp.getText().toString()), iRow, 2);
                    jtabCreds.setValueAt(jcbTrack.getSelectedItem().toString(), iRow, 3);
                    jtabCreds.setValueAt(sValue, iRow, 4);

                    jtabCreds.setValueAt(sValue, iRow, 4);
                    clearCredsFields();
                    enableCredsButtons();
                }
            }
        }
    });

    /// Button - Delete button for credentials
    btnCredDelete = new JButton("Delete");
    btnCredDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec.setType(Pwdtypes.S_CREDS_TYPE);
            dbRec.setCredId(iCredId);
            dbRec.setChallenge(jtxtChlng.getText().toString());
            dbRec.setResponse(jtxtRsp.getText().toString());
            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete credential record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabCreds.getModel();
                jtabModel.removeRow(jtabCreds.getSelectedRow());
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    /// Button - Clear button for credentials
    btnCredClear = new JButton("Clear");
    btnCredClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearCredsFields();
            enableCredsButtons();
        }
    });

    /// End section for credentials challenges/responses - text fields and buttons

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    btnShowAssoc = new JButton("Display Associated Challenges/Responses in new window");

    /// Display the challenges/responses associated to the application in a popup window. 
    /// This is to make it easier to view when all of the values are needed
    btnShowAssoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String sTitle = "Credentials for: " + jtxtApp.getText();
            String sDisplay = "";

            sDisplay += "\n";
            DefaultTableModel jTmpModel = (DefaultTableModel) jtabCreds.getModel();
            for (int i = 0; i < jTmpModel.getRowCount(); i++) {
                sDisplay += "Q. " + jTmpModel.getValueAt(i, 1).toString() + "  A. "
                        + l_crypto.decrypt(jTmpModel.getValueAt(i, 2).toString()) + "\n";
            }

            JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
        }
    });

    JLabel lblTrackUpdates = new JLabel("Exp Days");

    /// Values for expiration days are hardcoded, may want to move to a table for metadata
    jcbTrack.addItem("0");
    jcbTrack.addItem("30");
    jcbTrack.addItem("45");
    jcbTrack.addItem("60");
    jcbTrack.addItem("90");
    jcbTrack.addItem("180");
    jcbTrack.addItem("365");
    jcbTrack.setSelectedItem("0");

    btnEdit = new JButton("Edit");
    btnEdit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            jtxtChlng.setEnabled(true);
            jtxtRsp.setEnabled(true);
            jcbTrack.setEnabled(true);
            btnCredReplace.setEnabled(true);
            btnCredAdd.setEnabled(true);
        }
    });
    btnEdit.setEnabled(false);

    GroupLayout gl_contentPane = new GroupLayout(contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(207)
                            .addComponent(lblThePasswordSaver))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(23).addGroup(gl_contentPane
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createSequentialGroup().addComponent(btnAdd)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnReplace)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDelete)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnSearch)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnClear))
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.LEADING)
                                    .addGroup(gl_contentPane.createSequentialGroup()
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(lblUrlapplication)
                                                    .addComponent(lblDescription))
                                            .addPreferredGap(ComponentPlacement.RELATED)
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, 154,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE, 260,
                                                            GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 355,
                                            GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                            .addComponent(btnShowAssoc)
                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.TRAILING)
                                                            .addComponent(lblResponse)
                                                            .addComponent(lblChallenge))
                                                    .addGap(18)
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.LEADING)
                                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                                    .addComponent(jtxtRsp, 272, 272, 272)
                                                                    .addGap(26).addComponent(lblTrackUpdates)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(jcbTrack,
                                                                            GroupLayout.PREFERRED_SIZE, 55,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                                                    440, GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(gl_contentPane
                                                    .createParallelGroup(Alignment.LEADING, false)
                                                    .addGroup(gl_contentPane.createSequentialGroup()
                                                            .addComponent(btnCredAdd,
                                                                    GroupLayout.PREFERRED_SIZE, 78,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredReplace)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredDelete,
                                                                    GroupLayout.PREFERRED_SIZE, 75,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.UNRELATED)
                                                            .addComponent(btnCredClear)
                                                            .addPreferredGap(ComponentPlacement.RELATED,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(btnEdit))
                                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))))))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(36).addComponent(chkDelAssoc)))
                    .addContainerGap(57, Short.MAX_VALUE)));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addContainerGap().addComponent(lblThePasswordSaver)
                    .addGap(45)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.BASELINE).addComponent(lblUrlapplication)
                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblChallenge)).addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(lblDescription)
                                            .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblResponse)))
                            .addGroup(gl_contentPane.createSequentialGroup()
                                    .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(jtxtRsp, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblTrackUpdates)
                                            .addComponent(jcbTrack, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                    .addGap(18)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(btnAdd)
                            .addComponent(btnReplace).addComponent(btnDelete).addComponent(btnSearch)
                            .addComponent(btnClear).addComponent(btnCredAdd).addComponent(btnCredReplace)
                            .addComponent(btnCredDelete).addComponent(btnCredClear).addComponent(btnEdit))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 208,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 109,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_contentPane.createSequentialGroup().addGap(120)
                                    .addComponent(btnShowAssoc)))
                    .addGap(18).addComponent(chkDelAssoc).addContainerGap(170, Short.MAX_VALUE)));

    /// JTable - Credentials table setup/definition - BEGIN
    jtabCreds = new JTable();
    jtabCreds.setModel(new DefaultTableModel(new Object[][] {},
            new String[] { "ID", "Challenge", "Response", "Exp Days", "Expiration Date" }) {
        Class[] columnTypes = new Class[] { Integer.class, String.class, String.class, String.class,
                String.class };

        public Class getColumnClass(int columnIndex) {
            return columnTypes[columnIndex];
        }
    });
    jtabCreds.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    scrollPane_1.setViewportView(jtabCreds);
    /// JTable - Credentials table setup/definition - END

    jtabApps = new JTable();
    scrollPane.setViewportView(jtabApps);

    jtabApps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jtabApps.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    jtabApps.setModel(
            new DefaultTableModel(new Object[][] {}, new String[] { "ID", "URL/Application", "Description" }) {
                Class[] columnTypes = new Class[] { Integer.class, String.class, String.class };

                public Class getColumnClass(int columnIndex) {
                    return columnTypes[columnIndex];
                }

                @Override
                public boolean isCellEditable(int row, int column) {
                    //all cells false
                    return false;
                }
            });
    jtabApps.getColumnModel().getColumn(1).setMinWidth(55);
    jtabApps.getColumnModel().getColumn(2).setMinWidth(55);
    contentPane.setLayout(gl_contentPane);
    contentPane.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[] { jtxtChlng,
            lblThePasswordSaver, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear, jtxtRsp,
            btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, scrollPane, jtabApps, lblUrlapplication,
            lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));
    setFocusTraversalPolicy(new FocusTraversalOnArray(
            new Component[] { menuBar, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear,
                    jtxtChlng, jtxtRsp, btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, contentPane,
                    mnFile, mntmExit, lblThePasswordSaver, scrollPane, jtabApps, lblUrlapplication,
                    lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));

    /// Initial data load
    dbRec = new DbRecord();
    dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
    dbRec.setClientName("");
    dbRec.setClientDesc("");
    loadTable(dbRec);
    disableCredsButtons();

    ListSelectionModel rowSM = jtabApps.getSelectionModel();

    //Listener for client row change;
    rowSM.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iClientId = Integer.parseInt(jtabApps.getValueAt(iRow, 0).toString());
                jtxtApp.setText(jtabApps.getValueAt(iRow, 1).toString());
                jtxtDesc.setText(jtabApps.getValueAt(iRow, 2).toString());

                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                loadTable(dbRec);
                enableButtons();
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    ListSelectionModel rowCred = jtabCreds.getSelectionModel();

    //Listener for credential row change;
    rowCred.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iCredId = Integer.parseInt(jtabCreds.getValueAt(iRow, 0).toString());
                jtxtChlng.setText(jtabCreds.getValueAt(iRow, 1).toString());
                jtxtRsp.setText(l_crypto.decrypt(jtabCreds.getValueAt(iRow, 2).toString()));
                jcbTrack.setSelectedItem(jtabCreds.getValueAt(iRow, 3).toString());
                if (null == jtabCreds.getValueAt(iRow, 4)) {
                    sDateModified = "";
                } else {
                    sDateModified = jtabCreds.getValueAt(iRow, 4).toString();
                }
                sChallenge = jtxtChlng.getText();
                sResponse = jtxtRsp.getText();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setCredId(iClientId);
                jtxtChlng.setEnabled(false);
                jtxtRsp.setEnabled(false);
                jcbTrack.setEnabled(false);
                btnEdit.setEnabled(true);
                btnCredDelete.setEnabled(true);
                btnCredClear.setEnabled(true);
            }
        }
    });

}

From source file:org.springframework.richclient.layout.GridBagLayoutBuilder.java

/**
 * Appends a label and field to the end of the current line.<p />
 *
 * The label will be to the left of the field, and be right-justified.<br />
 * The field will "grow" horizontally as space allows.<p />
 *
 * @param label   the label to associate and layout with the field
 * @param colSpan the number of columns the field should span
 *
 * @return "this" to make it easier to string together append calls
 */// w w  w .j  a  va2  s . c  om
public GridBagLayoutBuilder appendLabeledField(final JLabel label, final JComponent field,
        LabelOrientation labelOrientation, int colSpan, int rowSpan, boolean expandX, boolean expandY) {
    label.setLabelFor(field);

    final int col = getCurrentCol();
    final int row = getCurrentRow();
    final Insets insets = getDefaultInsets();

    if (labelOrientation == LabelOrientation.LEFT || labelOrientation == null) {
        label.setHorizontalAlignment(SwingConstants.RIGHT);
        append(label, col, row, 1, 1, false, expandY, insets);
        append(field, col + 1, row, colSpan, rowSpan, expandX, expandY, insets);
    } else if (labelOrientation == LabelOrientation.RIGHT) {
        label.setHorizontalAlignment(SwingConstants.LEFT);
        append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
        append(label, col + colSpan, row, 1, rowSpan, false, expandY, insets);
    } else if (labelOrientation == LabelOrientation.TOP) {
        label.setHorizontalAlignment(SwingConstants.LEFT);
        append(label, col, row, colSpan, 1, expandX, false, insets);
        append(field, col, row + 1, colSpan, rowSpan, expandX, expandY, insets);
    } else if (labelOrientation == LabelOrientation.BOTTOM) {
        label.setHorizontalAlignment(SwingConstants.LEFT);
        append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
        append(label, col, row + rowSpan, colSpan, 1, expandX, false, insets);
    }

    return this;
}

From source file:org.springframework.richclient.layout.GridBagLayoutBuilder.java

/**
 * Appends a right-justified label to the end of the given line, using the
 * provided string as the key to look in the
 * {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
 * bundle for the text to use.//from   w  w  w  .  j  ava2 s .c  o  m
 *
 * @param labelKey the key into the message bundle; if not found the key is used
 *                 as the text to display
 * @param colSpan  the number of columns to span
 *
 * @return "this" to make it easier to string together append calls
 */
public GridBagLayoutBuilder appendRightLabel(String labelKey, int colSpan) {
    final JLabel label = createLabel(labelKey);
    label.setHorizontalAlignment(SwingConstants.RIGHT);
    return appendLabel(label, colSpan);
}

From source file:org.springframework.richclient.layout.GridBagLayoutBuilder.java

/**
 * Appends a left-justified label to the end of the given line, using the
 * provided string as the key to look in the
 * {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
 * bundle for the text to use.//w  ww  .ja v a  2 s  . com
 *
 * @param labelKey the key into the message bundle; if not found the key is used
 *                 as the text to display
 * @param colSpan  the number of columns to span
 *
 * @return "this" to make it easier to string together append calls
 */
public GridBagLayoutBuilder appendLeftLabel(String labelKey, int colSpan) {
    final JLabel label = createLabel(labelKey);
    label.setHorizontalAlignment(SwingConstants.LEFT);
    return appendLabel(label, colSpan);
}

From source file:org.stanwood.swing.AboutDialog.java

private void createTitleArea(Box box, String title, String version) {
    JLabel lblTitle = new JLabel(title);
    lblTitle.setHorizontalTextPosition(JLabel.LEFT);
    lblTitle.setHorizontalAlignment(JLabel.LEFT);
    lblTitle.setFont(new Font("Serif", Font.BOLD, 24));
    box.add(lblTitle);/*from  w  w  w .  j av  a  2  s.c o m*/
    JLabel lblVersion = new JLabel(version);
    lblVersion.setFont(new Font("Serif", Font.BOLD, 12));
    lblVersion.setHorizontalAlignment(JLabel.LEFT);
    lblVersion.setHorizontalTextPosition(JLabel.LEFT);
    box.add(lblVersion);
}