Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:org.mbs3.juniuploader.gui.pnlUploadSites.java

private void initGUI() {
    try {/*from   ww  w.  jav a 2  s .c  o m*/
        GridBagLayout thisLayout = new GridBagLayout();
        this.setLayout(thisLayout);
        {
            btnAddSite = new JButton();
            this.add(btnAddSite, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnAddSite.setText("Add Site to List");
            btnAddSite.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnAddSiteActionPerformed(evt);
                }
            });
        }
        {
            btnRemoveSite = new JButton();
            this.add(btnRemoveSite, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnRemoveSite.setText("Remove Selected Site");
            btnRemoveSite.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnRemoveSiteActionPerformed(evt);
                }
            });
        }
        {
            jScrollPane1 = new JScrollPane();
            this.add(jScrollPane1, new GridBagConstraints(1, 1, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            jScrollPane1.setPreferredSize(new java.awt.Dimension(367, 362));
            {
                lstUploadSites = new JList();
                jScrollPane1.setViewportView(lstUploadSites);
                lstUploadSites.setModel(frmMain.uploadLocations);
                lstUploadSites.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            }
        }
        thisLayout.rowWeights = new double[] { 0.0, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 9, 20, 7, 8, 7, 9 };
        thisLayout.columnWeights = new double[] { 0.0, 0.1, 0.0, 0.0, 0.0 };
        thisLayout.columnWidths = new int[] { 11, 20, 9, 217, 11 };
        this.setPreferredSize(new java.awt.Dimension(614, 382));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:components.TextDemo.java

public TextDemo() {
    super(new GridBagLayout());

    textField = new JTextField(20);
    textField.addActionListener(this);

    textArea = new JTextArea(5, 20);
    textArea.setEditable(false);/*from  w ww .j  a  va  2 s .com*/
    JScrollPane scrollPane = new JScrollPane(textArea);

    //Add Components to this panel.
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;

    c.fill = GridBagConstraints.HORIZONTAL;
    add(textField, c);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    add(scrollPane, c);
}

From source file:EditorPaneExample6.java

public EditorPaneExample6() {
    super("JEditorPane Example 6");

    pane = new JEditorPane();
    pane.setEditable(false); // Start read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//  w w w  .j a  v  a 2 s .co  m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    c.gridwidth = 2;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    // Add a "Save" button
    saveButton = new JButton("Save");
    saveButton.setEnabled(false);
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 0;
    c.weightx = 0.0;
    panel.add(saveButton, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String fileName = textField.getText().trim();
            file = new File(fileName);
            absolutePath = file.getAbsolutePath();
            String url = "file:///" + absolutePath;

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);

                saveButton.setEnabled(false);
                saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setEditable(false);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");

                textField.setEnabled(true); // Allow entry of new file name
                textField.requestFocus();
                setCursor(Cursor.getDefaultCursor());

                // Allow editing and saving if appropriate
                pane.setEditable(file.canWrite());
                saveButton.setEnabled(file.canWrite());
            }
        }
    });

    // Save button
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                String type = pane.getContentType();
                OutputStream os = new BufferedOutputStream(new FileOutputStream(file + ".save"));
                pane.setEditable(false);
                textField.setEnabled(false);
                saveButton.setEnabled(false);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                Document doc = pane.getDocument();
                int length = doc.getLength();
                if (type.endsWith("/rtf")) {
                    // Saving RTF - use the OutputStream
                    try {
                        pane.getEditorKit().write(os, doc, 0, length);
                        os.close();
                    } catch (BadLocationException ex) {
                    }
                } else {
                    // Not RTF - use a Writer.
                    Writer w = new OutputStreamWriter(os);
                    pane.write(w);
                    w.close();
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to save file", file.getAbsolutePath(), }, "File Save Error",
                        JOptionPane.ERROR_MESSAGE);

            }
            pane.setEditable(file.canWrite());
            textField.setEnabled(true);
            saveButton.setEnabled(file.canWrite());
            setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:EditorPaneExample7.java

public EditorPaneExample7() {
    super("JEditorPane Example 7");

    pane = new JEditorPane();
    pane.setEditable(false); // Start read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from  ww w  .ja v  a2s. co  m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    c.gridwidth = 2;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    getContentPane().add(panel, "South");

    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    saveButton = new JButton("Save");
    plain = new JCheckBox("Plain Text");
    html = new JCheckBox("HTML");
    rtf = new JCheckBox("RTF");
    panel.add(plain);
    panel.add(html);
    panel.add(rtf);

    ButtonGroup group = new ButtonGroup();
    group.add(plain);
    group.add(html);
    group.add(rtf);
    plain.setSelected(true);

    panel.add(Box.createVerticalStrut(10));
    panel.add(saveButton);
    panel.add(Box.createVerticalGlue());
    panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));

    getContentPane().add(panel, "East");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String fileName = textField.getText().trim();
            file = new File(fileName);
            absolutePath = file.getAbsolutePath();
            String url = "file:///" + absolutePath;

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);

                saveButton.setEnabled(false);
                saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setEditable(false);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");

                textField.setEnabled(true); // Allow entry of new file name
                textField.requestFocus();
                setCursor(Cursor.getDefaultCursor());

                // Allow editing and saving if appropriate
                pane.setEditable(file.canWrite());
                saveButton.setEnabled(file.canWrite());
            }
        }
    });

    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Writer w = null;
            OutputStream os = System.out;
            String contentType;
            if (plain.isSelected()) {
                contentType = "text/plain";
                w = new OutputStreamWriter(os);
            } else if (html.isSelected()) {
                contentType = "text/html";
                w = new OutputStreamWriter(os);
            } else {
                contentType = "text/rtf";
            }

            EditorKit kit = pane.getEditorKitForContentType(contentType);
            try {
                if (w != null) {
                    kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength());
                    w.flush();
                } else {
                    kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength());
                    os.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });
}

From source file:org.mbs3.juniuploader.gui.pnlFormVariables.java

private void initGUI() {
    try {/*from   www.  j a v  a  2  s  . co m*/
        GridBagLayout thisLayout = new GridBagLayout();
        this.setLayout(thisLayout);
        {
            btnAddPair = new JButton();
            this.add(btnAddPair, new GridBagConstraints(3, 3, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnAddPair.setText("Add a New Pair");
            btnAddPair.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnAddPairActionPerformed(evt);
                }
            });
        }
        {
            btnRemPair = new JButton();
            this.add(btnRemPair, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnRemPair.setText("Remove Selected Pair");
            btnRemPair.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnRemPairActionPerformed(evt);
                }
            });
        }
        {

            cmbFormGroups = new JComboBox();
            this.add(cmbFormGroups, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            cmbFormGroups.setModel(frmMain.formGroups);
            cmbFormGroups.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    cmbFormGroupsItemStateChanged(evt);
                }
            });
        }
        {

            DefaultComboBoxModel groups = frmMain.formGroups;
            FormPairGroup fpg = (FormPairGroup) groups.getSelectedItem();
            DefaultComboBoxModel dcbmFormPairs;
            if (fpg != null)
                dcbmFormPairs = new DefaultComboBoxModel(fpg.getPairs());
            else
                dcbmFormPairs = new DefaultComboBoxModel();

            lstFormPairValues = new JList();
            lstFormPairValues.setModel(dcbmFormPairs);

            this.add(lstFormPairValues, new GridBagConstraints(1, 3, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            lstFormPairValues.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        }

        {
            btnAddGroup = new JButton();
            this.add(btnAddGroup, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnAddGroup.setText("Add a Group");
            btnAddGroup.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnAddGroupActionPerformed(evt);
                }
            });
        }
        {
            btnRemSelGrp = new JButton();
            this.add(btnRemSelGrp, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnRemSelGrp.setText("Remove This Group");
            btnRemSelGrp.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnRemSelGrpActionPerformed(evt);
                }
            });
        }
        {
            btnEditPair = new JButton();
            this.add(btnEditPair, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnEditPair.setText("Edit This Pair");
            btnEditPair.setEnabled(false);
        }
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 8, 24, 9, 20, 7, 8, 7, 9 };
        thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
        thisLayout.columnWidths = new int[] { 11, 335, 9, 97, 10, 119, 10 };
        this.setPreferredSize(new java.awt.Dimension(614, 382));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.af.gMCP.gui.dialogs.TellAboutOnlineUpate.java

public TellAboutOnlineUpate(JFrame mainFrame) {
    super(mainFrame, "Check for online updates, privacy statement and license", true);

    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    jtAbout.setStyledDocument(getDocument());
    jtAbout.setEditable(false);//from   w w w  . j  a v a  2  s .c  o m

    JTextArea jta3 = new JTextArea("gMCP - Graph based Multiple Comparison Procedures.\n"
            + "Copyright (C) 2009-2014 by K. Rohmeyer and F. Klinglmueller\n" + "\n"
            + "This program is free software; you can redistribute it and/or\n"
            + "modify it under the terms of the GNU General Public License\n"
            + "as published by the Free Software Foundation; either version 2\n"
            + "of the License, or (at your option) any later version.\n" + "\n"
            + "This program is distributed in the hope that it will be useful,\n"
            + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
            + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
            + "GNU General Public License for more details. It is included\n"
            + "in the R distribution (in directory share/licenses) or can be\n"
            + "found at: http://www.gnu.org/licenses/\n");
    jta3.setFont(new Font("Monospaced", Font.PLAIN, 10));

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 10;
    c.ipady = 10;
    c.weightx = 1;
    c.weighty = 1;

    checkOnlineForUpdate.setSelected(Configuration.getInstance().getGeneralConfig().checkOnline());

    c.gridx = 0;
    (getContentPane()).add(jtAbout, c);
    c.gridy++;
    (getContentPane()).add(checkOnlineForUpdate, c);
    c.gridy++;
    c.weighty = 1;
    JScrollPane js = new JScrollPane(jta3);
    (getContentPane()).add(js, c);

    Container cp = getContentPane();
    cp = WidgetFactory.makeDialogPanelWithButtons(cp, new OKButtonPane(), this);
    setContentPane(cp);

    pack();

    setLocationRelativeTo(mainFrame);

    setVisible(true);
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.ClotureMensuellePayePanel.java

public ClotureMensuellePayePanel() {

    super();/*from  w w  w .  j  a va2 s  .c o  m*/

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(2, 2, 1, 2);
    c.weightx = 0;
    c.weighty = 0;
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 0;

    JLabel labelMois = new JLabel("Cloture du mois de ");
    this.add(labelMois, c);

    final ElementComboBox selMois = new ElementComboBox(true, 25);
    selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory()
            .getElement(MoisSQLElement.class));
    selMois.setButtonsVisible(false);
    c.gridx++;
    this.add(selMois, c);

    JLabel labelAnnee = new JLabel("Anne");
    c.gridx++;
    this.add(labelAnnee, c);
    final JTextField textAnnee = new JTextField(5);
    c.gridx++;
    this.add(textAnnee, c);
    DateFormat format = new SimpleDateFormat("yyyy");
    textAnnee.setText(format.format(new Date()));

    c.gridy++;
    c.gridx = 0;
    final JCheckBox boxValid = new JCheckBox("Valider toutes les payes du mois");
    final JCheckBox boxCompta = new JCheckBox("Gnrer les critures comptables associes");
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(boxValid, c);
    boxValid.setSelected(true);
    c.gridy++;
    this.add(boxCompta, c);

    JButton buttonClot = new JButton("Clturer");
    JButton buttonFermer = new JButton("Fermer");

    JPanel panelButton = new JPanel();
    panelButton.add(buttonClot);
    panelButton.add(buttonFermer);
    c.anchor = GridBagConstraints.SOUTHEAST;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 1;
    c.gridy++;
    this.add(panelButton, c);

    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(ClotureMensuellePayePanel.this)).dispose();
        }
    });

    buttonClot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {

                // Valider les fiches non valids des salaris actifs
                if (boxValid.isSelected()) {
                    SQLSelect selFiche = new SQLSelect();
                    SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE");
                    SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE");
                    SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE");
                    selFiche.addSelect(tableFiche.getField("ID"));

                    selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.FALSE));
                    selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId()));
                    selFiche.andWhere(
                            new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));
                    selFiche.andWhere(
                            new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE")));
                    selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=",
                            tableSalarie.getField("ID_INFOS_SALARIE_PAYE")));

                    // FIXME ne pas valider les fiches d'un employ renvoy

                    // Where w2 = new Where(tableInfosSal.getField("DATE_SORTIE"), "IS",
                    // "NULL");
                    Calendar cal = Calendar.getInstance();
                    cal.set(Calendar.DATE, 1);
                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                    cal.set(Calendar.YEAR, Integer.parseInt(textAnnee.getText()));
                    cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));

                    Where w = new Where(tableInfosSal.getField("DATE_SORTIE"), "<=", cal.getTime());
                    w = w.or(new Where(tableInfosSal.getField("DATE_SORTIE"), "=", (Object) null));
                    selFiche.andWhere(w);
                    String req = selFiche.asString();
                    System.err.println(req);
                    List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req,
                            new ArrayListHandler());

                    for (int i = 0; i < l.size(); i++) {

                        Object[] tmp = (Object[]) l.get(i);
                        SQLRow rowFicheTmp = tableFiche.getRow(Integer.parseInt(tmp[0].toString()));
                        System.err.println(rowFicheTmp);
                        FichePayeSQLElement.validationFiche(rowFicheTmp.getID());
                    }
                }

                // cloture du mois et generation compta

                SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base);
                SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE");
                SQLTable tableMois = ClotureMensuellePayePanel.this.base.getTable("MOIS");
                selFiche.addSelect(tableFiche.getField("ID"));

                selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.TRUE));
                selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId()));
                selFiche.andWhere(
                        new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));

                String req = selFiche.asString();

                List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req,
                        new ArrayListHandler());

                if (l != null && l.size() > 0) {
                    int[] idS = new int[l.size()];
                    SQLRow rowMois = tableMois.getRow(selMois.getSelectedId());

                    for (int i = 0; i < l.size(); i++) {

                        Object[] tmp = (Object[]) l.get(i);
                        idS[i] = Integer.parseInt(tmp[0].toString());
                        SQLRow rowFiche = tableFiche.getRow(idS[i]);
                        FichePayeSQLElement.clotureMensuelle(selMois.getSelectedId(),
                                Integer.parseInt(textAnnee.getText()), rowFiche.getInt("ID_SALARIE"));
                    }
                    if (boxCompta.isSelected()) {
                        new GenerationMvtFichePaye(idS, rowMois.getString("NOM"), textAnnee.getText());
                    }
                }
                System.err.println(
                        "ClotureMensuellePayePanel.ClotureMensuellePayePanel().new ActionListener() {...}.actionPerformed()");
                JOptionPane.showMessageDialog(null, "Clture termine");
            } catch (Exception ex) {
                ExceptionHandler.handle("Unable to complete operation", ex);
            }
        }
    });
}

From source file:org.mbs3.juniuploader.gui.pnlAbout.java

private void initGUI() {
    try {/*w w  w.  j  ava2  s . c  o  m*/
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.1, 0.0, 0.0, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 7, 25, 20, 8, 23, 20, 6 };
        thisLayout.columnWeights = new double[] { 0.0, 0.1, 0.1 };
        thisLayout.columnWidths = new int[] { 11, 7, 20 };
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(626, 368));
        {
            lblImage1 = new JLabel();
            File fImage = new File("logo1.gif");
            if (fImage != null & fImage.canRead()) {
                ImageIcon i = new ImageIcon(fImage.getAbsolutePath());
                lblImage1.setIcon(i);
            }
            this.add(lblImage1, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
        {
            lblLogo1Desc = new JLabel();
            this.add(getLblLogo1Desc(), new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblLogo1Desc.setText("Logo2:");
        }
        {
            jLabel1 = new JLabel();
            this.add(jLabel1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            jLabel1.setText("Logo1:");
        }
        {
            lblImage2 = new JLabel();
            File fImage2 = new File("logo2.gif");
            if (fImage2 != null & fImage2.canRead()) {
                ImageIcon i = new ImageIcon(fImage2.getAbsolutePath());
                lblImage2.setIcon(i);
            }

            this.add(lblImage2, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
    } catch (Exception ex) {
        log.error("initGui() exception", ex);
    }
}

From source file:eu.dety.burp.joseph.utilities.Converter.java

/**
 * Get RSA PublicKey by PublicKey HashMap input. Create a dialog popup with a combobox to choose the correct JWK to use.
 * //from  ww w.ja v a  2  s .  c o m
 * @param publicKeys
 *            HashMap containing a PublicKey and related describing string
 * @throws AttackPreparationFailedException
 * @return Selected {@link PublicKey}
 */
@SuppressWarnings("unchecked")
public static PublicKey getRsaPublicKeyByJwkSelectionPanel(HashMap<String, PublicKey> publicKeys)
        throws AttackPreparationFailedException {
    // TODO: Move to other class?
    JPanel selectionPanel = new JPanel();
    selectionPanel.setLayout(new java.awt.GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;

    constraints.gridy = 0;
    selectionPanel.add(new JLabel("Multiple JWKs found. Please choose one:"), constraints);

    JComboBox jwkSetKeySelection = new JComboBox<>();
    DefaultComboBoxModel<String> jwkSetKeySelectionModel = new DefaultComboBoxModel<>();

    for (Map.Entry<String, PublicKey> publicKey : publicKeys.entrySet()) {
        jwkSetKeySelectionModel.addElement(publicKey.getKey());
    }

    jwkSetKeySelection.setModel(jwkSetKeySelectionModel);

    constraints.gridy = 1;
    selectionPanel.add(jwkSetKeySelection, constraints);

    int resultButton = JOptionPane.showConfirmDialog(null, selectionPanel, "Select JWK",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

    if (resultButton == JOptionPane.CANCEL_OPTION) {
        throw new AttackPreparationFailedException("No JWK from JWK Set selected!");
    }

    loggerInstance.log(Converter.class, "Key selected: " + jwkSetKeySelection.getSelectedIndex(),
            Logger.LogLevel.DEBUG);
    return publicKeys.get(jwkSetKeySelection.getSelectedItem());
}

From source file:client.gui.ConnectionDialog.java

public ConnectionDialog() {

    connect = new JButton("Connect");
    connectDev = new JButton("Connect (Developer)");
    connectSame = new JButton("Connect (a as nick)");

    nick = new JTextField();
    host = new JTextField();
    port = new JTextField();

    setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();

    setSize(new Dimension(400, 200));

    host.setPreferredSize(new Dimension(200, 24));

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;//  www .j a va  2 s.  co m
    c.gridx = 0;
    c.gridy = 0;
    add(new JLabel("Nick:"), c);
    c.gridy = 1;
    add(new JLabel("Host:"), c);
    c.gridy = 2;
    add(new JLabel("Port:"), c);

    c.gridx = 1;

    c.gridy = 0;
    add(nick, c);

    c.gridy = 1;
    add(host, c);

    c.gridy = 2;
    add(port, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    add(connect, c);

    // c.gridy = 4;
    // add(connectDev, c);

    //  c.gridy = 5;
    //  add(connectSame, c);

    connect.addActionListener(this);
    connectDev.addActionListener(this);
    connectSame.addActionListener(this);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(final WindowEvent event) {
            dispose();
        }
    });

    final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);

}