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:com.att.aro.ui.view.videotab.VideoTab.java

private JPanel getTitledWrapper(String title, JComponent component) {

    JPanel pane = new JPanel(new GridBagLayout());

    pane.setOpaque(false);//w  w w  .  jav a2s .  co m
    pane.setBorder(new RoundedBorder(new Insets(0, 10, 10, 10), Color.WHITE));

    JPanel fullPanel = new JPanel(new BorderLayout());

    fullPanel.setOpaque(false);

    // Create the header bar
    BpHeaderPanel header = new BpHeaderPanel(ResourceBundleHelper.getMessageString(title));
    header.setImageTitle(Images.BLUE_HEADER.getImage(), null);
    if (component != null) {
        header.add(component, BorderLayout.EAST);
    }
    fullPanel.add(header, BorderLayout.NORTH);
    pane.add(fullPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, headInsets, 0, 0));
    return pane;
}

From source file:algorithm.QRCodeWatermarking.java

/**
 * Creates the GUI that is used to configure this algorithm.
 *//*from   w  ww  . j ava2  s  .c  om*/
private void createConfigurationGui() {
    initButtons();
    panel = new GUIPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.gridwidth = 2;
    panel.add(new JLabel("<html><h2>QR-code options</h2></html>"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("QR-code size: "), constraints);
    constraints.gridx++;
    sizeField.setText("200");
    panel.add(sizeField, constraints);
    constraints.gridwidth = 2;
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    constraints.gridx = 0;
    constraints.gridwidth = 1;
    panel.add(new JLabel("Select output file format:"), constraints);
    constraints.gridx++;
    panel.add(imageFormatBox, constraints);
    constraints.gridx = 0;
    constraints.gridy++;

    // separate file:
    constraints.gridwidth = 2;
    panel.add(falseEncapsulate, constraints);
    constraints.gridy++;
    constraints.gridy++;

    // add to carrier:
    panel.add(trueEncapsulate, constraints);
    constraints.gridy++;

    JTextArea infoArea = new JTextArea();
    infoArea.setText("" + "\nPlease note: "
            + "\n- The QR-code will be created from the first payload file, if the dataset has more than one payload files, and added to each carrier file. "
            + "All other payload files will be ignored, if this option is selected."
            + "\n- Carrier files need to be one of the following file types:"
            + "\n\tpng, jpeg, jp2, jpg, bmp, gif" + "\n- All carrier files of other file formats are ignored."
            + "\n- The QR-code pixel size should exceed the carrier image size in no dimension."
            + "\n- If the size of the selected payload file is too big to create a QR-code from it, you will get an error message."
            + "\n\n" + "Options for adding the QR-code to the carrier images:");
    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    panel.add(infoArea, constraints);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridy++;
    panel.add(new JLabel("On which image position should the barcode be added?"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("X :"), constraints);
    constraints.gridx++;
    xPositionField.setText("0");
    panel.add(xPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    panel.add(new JLabel("Y :"), constraints);
    constraints.gridx++;
    yPositionField.setText("0");
    panel.add(yPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    panel.add(messageLabel, constraints);
}

From source file:junk.gui.HazardDataSetCalcCondorApp.java

private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, new Color(248, 254, 255), new Color(121, 124, 136));
    this.setSize(new Dimension(564, 834));
    this.getContentPane().setLayout(borderLayout1);
    mainPanel.setBorder(border1);/*from  w  w w.  j a  v a2  s .  c  om*/
    mainPanel.setLayout(gridBagLayout);
    mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    buttonPanel.setLayout(borderLayout3);
    eqkRupPanel.setLayout(gridBagLayout);
    imr_IMTSplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
    imrPanel.setLayout(borderLayout2);
    imtPanel.setLayout(gridBagLayout);
    buttonPanel.setMinimumSize(new Dimension(391, 50));
    gridRegionSitePanel.setLayout(gridBagLayout);
    imrSelectionPanel.setLayout(gridBagLayout);
    //controlComboBox.setBackground(Color.white);
    dataPanel.setLayout(gridBagLayout4);
    imgPanel.setLayout(gridBagLayout7);
    addButton.setBorder(null);
    addButton.setText("Start Calc");
    addButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addButton_actionPerformed(e);
        }
    });
    controlComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            controlComboBox_actionPerformed(e);
        }
    });
    emailLabel.setText("Email:");
    datasetLabel.setText("Dataset Id:");
    emailText.setText("");
    dataPanel.setMinimumSize(new Dimension(548, 150));
    dataPanel.setPreferredSize(new Dimension(549, 150));
    this.getContentPane().add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(mainSplitPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(1, 1, 2, 3), 0, 431));
    mainSplitPane.add(buttonPanel, JSplitPane.BOTTOM);
    buttonPanel.add(dataPanel, BorderLayout.CENTER);
    dataPanel.add(datasetIdText, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(34, 19, 81, 0), 162, 7));
    dataPanel.add(datasetLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(34, 7, 81, 0), 28, 10));
    dataPanel.add(emailText, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(43, 19, 0, 0), 162, 7));
    dataPanel.add(controlComboBox, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(43, 48, 0, 24), 35, 2));
    dataPanel.add(emailLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(43, 7, 0, 15), 43, 12));
    dataPanel.add(addButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(27, 51, 81, 24), 79, 12));
    buttonPanel.add(imgPanel, BorderLayout.SOUTH);
    imgPanel.add(imgLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(15, 235, 3, 246), 57, 28));
    mainSplitPane.add(parameterTabbedPanel, JSplitPane.TOP);
    imr_IMTSplit.add(imtPanel, JSplitPane.BOTTOM);
    imr_IMTSplit.add(imrSelectionPanel, JSplitPane.TOP);
    imrPanel.add(imr_IMTSplit, BorderLayout.CENTER);
    parameterTabbedPanel.addTab("Intensity-Measure Relationship", imrPanel);
    parameterTabbedPanel.addTab("Region & Site Params", gridRegionSitePanel);
    parameterTabbedPanel.addTab("Earthquake Rupture Forecast", eqkRupPanel);
    mainSplitPane.setDividerLocation(550);
    imr_IMTSplit.setDividerLocation(300);
    imgLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            imgLabel_mouseClicked(e);
        }
    });

}

From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//from   w  w w  .jav a2s . c  o  m
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();

    // TODO: Add bag name field
    // TODO: Add save name file selection button
    final JLabel location = new JLabel("Save in:");
    final JButton browseButton = new JButton(getMessage("bag.button.browse"));
    browseButton.addActionListener(new SaveBagAsHandler());
    browseButton.setEnabled(true);
    browseButton.setToolTipText(getMessage("bag.button.browse.help"));
    final DefaultBag bag = bagView.getBag();
    if (bag != null) {
        bagNameField = new JTextField(bag.getName());
        bagNameField.setCaretPosition(bag.getName().length());
        bagNameField.setEditable(false);
        bagNameField.setEnabled(false);
    }

    // Holey bag control
    final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey"));
    holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));
    final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey"));
    holeyCheckbox.setBorder(border);
    holeyCheckbox.addActionListener(new HoleyBagHandler());
    holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlField = new JTextField("");
    try {
        assert bag != null;
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    final JLabel serializeLabel;
    serializeLabel = new JLabel(getMessage("bag.label.ispackage"));
    serializeLabel.setToolTipText(getMessage("bag.serializetype.help"));

    // TODO: Add format selection panel
    noneButton = new JRadioButton(getMessage("bag.serializetype.none"));
    noneButton.setEnabled(true);
    final AbstractAction serializeListener = new SerializeBagHandler();
    noneButton.addActionListener(serializeListener);
    noneButton.setToolTipText(getMessage("bag.serializetype.none.help"));

    zipButton = new JRadioButton(getMessage("bag.serializetype.zip"));
    zipButton.setEnabled(true);
    zipButton.addActionListener(serializeListener);
    zipButton.setToolTipText(getMessage("bag.serializetype.zip.help"));

    /*
     * tarButton = new JRadioButton(getMessage("bag.serializetype.tar"));
     * tarButton.setEnabled(true);
     * tarButton.addActionListener(serializeListener);
     * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help"));
     *
     * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz"));
     * tarGzButton.setEnabled(true);
     * tarGzButton.addActionListener(serializeListener);
     * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help"));
     *
     * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2"));
     * tarBz2Button.setEnabled(true);
     * tarBz2Button.addActionListener(serializeListener);
     * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help"));
     */

    short mode = 2;
    if (bag != null) {
        mode = bag.getSerialMode();
    }
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } else {
        this.noneButton.setEnabled(true);
    }

    final ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    // serializeGroup.add(tarButton);
    // serializeGroup.add(tarGzButton);
    // serializeGroup.add(tarBz2Button);
    final JPanel serializeGroupPanel = new JPanel(new FlowLayout());
    serializeGroupPanel.add(serializeLabel);
    serializeGroupPanel.add(noneButton);
    serializeGroupPanel.add(zipButton);
    // serializeGroupPanel.add(tarButton);
    // serializeGroupPanel.add(tarGzButton);
    // serializeGroupPanel.add(tarBz2Button);
    serializeGroupPanel.setBorder(border);
    serializeGroupPanel.setEnabled(true);
    serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help"));

    final JLabel tagLabel = new JLabel(getMessage("bag.label.istag"));
    tagLabel.setToolTipText(getMessage("bag.label.istag.help"));
    final JCheckBox isTagCheckbox = new JCheckBox();
    isTagCheckbox.setBorder(border);
    isTagCheckbox.addActionListener(new TagManifestHandler());
    isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help"));

    final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm"));
    tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help"));
    final ArrayList<String> listModel = new ArrayList<>();
    for (final Algorithm algorithm : Algorithm.values()) {
        listModel.add(algorithm.bagItAlgorithm);
    }
    final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()]));
    tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist"));
    tagAlgorithmList.addActionListener(new TagAlgorithmListHandler());
    tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help"));

    final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload"));
    payloadLabel.setToolTipText(getMessage("bag.ispayload.help"));
    final JCheckBox isPayloadCheckbox = new JCheckBox();
    isPayloadCheckbox.setBorder(border);
    isPayloadCheckbox.addActionListener(new PayloadManifestHandler());
    isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help"));

    final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    final JComboBox<String> payAlgorithmList = new JComboBox<String>(
            listModel.toArray(new String[listModel.size()]));
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    //only if bag is not null
    if (bag != null) {
        final String fileName = bag.getName();
        bagNameField = new JTextField(fileName);
        bagNameField.setCaretPosition(fileName.length());

        holeyCheckbox.setSelected(bag.isHoley());
        urlLabel.setEnabled(bag.isHoley());
        isTagCheckbox.setSelected(bag.isBuildTagManifest());
        tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
        isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
        payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(location, glbc);
    panel.add(location);

    buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST);
    glbc.ipadx = 5;
    layout.setConstraints(browseButton, glbc);
    glbc.ipadx = 0;
    panel.add(browseButton);

    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    glbc.ipadx = 5;
    layout.setConstraints(bagNameField, glbc);
    glbc.ipadx = 0;
    panel.add(bagNameField);

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(holeyLabel, glbc);
    panel.add(holeyLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST);
    layout.setConstraints(holeyCheckbox, glbc);
    panel.add(holeyCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(serializeLabel, glbc);
    panel.add(serializeLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    layout.setConstraints(serializeGroupPanel, glbc);
    panel.add(serializeGroupPanel);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagLabel, glbc);
    panel.add(tagLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isTagCheckbox, glbc);
    panel.add(isTagCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagAlgorithmLabel, glbc);
    panel.add(tagAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(tagAlgorithmList, glbc);
    panel.add(tagAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payloadLabel, glbc);
    panel.add(payloadLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isPayloadCheckbox, glbc);
    panel.add(isPayloadCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payAlgorithmLabel, glbc);
    panel.add(payAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(payAlgorithmList, glbc);
    panel.add(payAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:net.sourceforge.squirrel_sql.client.gui.ProgressAbortDialog.java

private void createGUI() {
    JPanel dialogPanel = new JPanel(new GridBagLayout());
    dialogPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
    GridBagConstraints c;/* w  w w . java  2s.c  o m*/

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 0.5;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(4, 0, 4, 0);
    taskDescriptionComponent = createTaskDescripion();
    dialogPanel.add(taskDescriptionComponent, c);

    c.gridy++;
    JPanel progressPanel = new JPanel(new GridBagLayout());
    progressPanel.setMinimumSize(new Dimension(400, 200));
    progressPanel.setPreferredSize(new Dimension(400, 200));
    progressPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
    dialogPanel.add(progressPanel, c);

    c.gridy = 0;
    c.gridx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = new Insets(4, 10, 4, 10);
    statusLabel = new JLabel(i18n.INITIAL_LOADING_PREFIX);
    progressPanel.add(statusLabel, c);

    c.gridy++;
    c.insets = new Insets(4, 10, 4, 10);
    additionalStatusLabel = new JLabel(" "); // Must be a space :-)
    progressPanel.add(additionalStatusLabel, c);

    c.gridy++;
    c.weightx = 1.0;
    progressBar = new JProgressBar(0, itemCount);
    progressBar.setIndeterminate(indeterminate);
    progressPanel.add(progressBar, c);

    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    historyArea = new JTextArea();
    historyArea.setEditable(false);
    JScrollPane jScrollPane = new JScrollPane(historyArea);
    progressPanel.add(jScrollPane, c);

    if (abortHandler != null) {
        cancelButton = new JButton(new CancelAction());

        c.gridy++;
        c.anchor = GridBagConstraints.WEST;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0.0;
        c.weighty = 0.0;
        dialogPanel.add(cancelButton, c);
    }

    super.getContentPane().add(dialogPanel);
    super.pack();
    super.setSize(new Dimension(450, 450));
    super.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    super.addWindowListener(new WindowCloseListener());
}

From source file:com.openbravo.pos.panels.JTicketsFinder.java

/** This method is called from within the constructor to
 * initialize the form.//from w ww . j  av  a2  s .co  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jPanel3 = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jtxtMoney = new com.openbravo.editor.JEditorCurrency();
    jcboUser = new javax.swing.JComboBox();
    jcboMoney = new javax.swing.JComboBox();
    jtxtTicketID = new com.openbravo.editor.JEditorIntegerPositive();
    labelCustomer = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jTxtStartDate = new javax.swing.JTextField();
    jTxtEndDate = new javax.swing.JTextField();
    btnDateStart = new javax.swing.JButton();
    btnDateEnd = new javax.swing.JButton();
    jtxtCustomer = new javax.swing.JTextField();
    btnCustomer = new javax.swing.JButton();
    jComboBoxTicket = new javax.swing.JComboBox();
    jLabel2 = new javax.swing.JLabel();
    jtxtCodebar = new javax.swing.JTextField();
    jEditProduct = new javax.swing.JButton();
    jPanel6 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jPanel4 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jListTickets = new javax.swing.JList();
    jPanel8 = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    jcmdCancel = new javax.swing.JButton();
    jcmdOK = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    m_jKeys = new com.openbravo.editor.JEditorKeys();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(AppLocal.getIntString("form.tickettitle")); // NOI18N

    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel5.setLayout(new java.awt.BorderLayout());

    jPanel7.setPreferredSize(new java.awt.Dimension(10, 250));
    jPanel7.setLayout(new java.awt.GridBagLayout());

    jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel1.setText(AppLocal.getIntString("label.ticketid")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel1, gridBagConstraints);

    jLabel6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel6.setText(AppLocal.getIntString("label.user")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel6, gridBagConstraints);

    jLabel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel7.setText(AppLocal.getIntString("label.totalcash")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel7, gridBagConstraints);

    jtxtMoney.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
    jPanel7.add(jtxtMoney, gridBagConstraints);

    jcboUser.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
    jcboUser.setPreferredSize(new java.awt.Dimension(200, 25));
    jcboUser.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jcboUserItemStateChanged(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
    jPanel7.add(jcboUser, gridBagConstraints);

    jcboMoney.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
    jPanel7.add(jcboMoney, gridBagConstraints);

    jtxtTicketID.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jtxtTicketID, gridBagConstraints);

    labelCustomer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    labelCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(labelCustomer, gridBagConstraints);

    jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel3.setText(AppLocal.getIntString("Label.StartDate")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel3, gridBagConstraints);

    jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel4.setText(AppLocal.getIntString("Label.EndDate")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel4, gridBagConstraints);

    jTxtStartDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jTxtStartDate.setPreferredSize(new java.awt.Dimension(200, 25));
    jTxtStartDate.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            jTxtEndDateKeyReleased(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jTxtStartDate, gridBagConstraints);

    jTxtEndDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jTxtEndDate.setPreferredSize(new java.awt.Dimension(200, 25));
    jTxtEndDate.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            jTxtEndDateKeyReleased(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jTxtEndDate, gridBagConstraints);

    btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N
    btnDateStart.setToolTipText("Open Calendar");
    btnDateStart.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnDateStartActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(btnDateStart, gridBagConstraints);

    btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N
    btnDateEnd.setToolTipText("Open Calendar");
    btnDateEnd.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnDateEndActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(btnDateEnd, gridBagConstraints);

    jtxtCustomer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jtxtCustomer.setPreferredSize(new java.awt.Dimension(200, 25));
    jtxtCustomer.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            jTxtEndDateKeyReleased(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jtxtCustomer, gridBagConstraints);

    btnCustomer.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/customer_sml.png"))); // NOI18N
    btnCustomer.setToolTipText("Open Customers");
    btnCustomer.setFocusPainted(false);
    btnCustomer.setFocusable(false);
    btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14));
    btnCustomer.setPreferredSize(new java.awt.Dimension(57, 33));
    btnCustomer.setRequestFocusEnabled(false);
    btnCustomer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCustomerActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(btnCustomer, gridBagConstraints);

    jComboBoxTicket.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jComboBoxTicket, gridBagConstraints);

    jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel2.setText(AppLocal.getIntString("label.prodbarcode"));
    jLabel2.setPreferredSize(new java.awt.Dimension(95, 14));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jLabel2, gridBagConstraints);

    jtxtCodebar.setPreferredSize(new java.awt.Dimension(200, 25));
    jtxtCodebar.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            jTxtEndDateKeyReleased(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
    jPanel7.add(jtxtCodebar, gridBagConstraints);

    jEditProduct
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/search24.png"))); // NOI18N
    jEditProduct.setMargin(new java.awt.Insets(8, 14, 8, 14));
    jEditProduct.setPreferredSize(new java.awt.Dimension(57, 33));
    jEditProduct.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jEditProductActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel7.add(jEditProduct, gridBagConstraints);

    jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

    jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/reload.png"))); // NOI18N
    jButton1.setText(AppLocal.getIntString("button.clean")); // NOI18N
    jButton1.setToolTipText("Clear Filter");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton1);

    jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N
    jButton3.setToolTipText("Execute Filter");
    jButton3.setFocusPainted(false);
    jButton3.setFocusable(false);
    jButton3.setRequestFocusEnabled(false);
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton3);

    jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH);

    jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START);

    jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jPanel4.setLayout(new java.awt.BorderLayout());

    jListTickets.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    jListTickets.setFocusable(false);
    jListTickets.setRequestFocusEnabled(false);
    jListTickets.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jListTicketsMouseClicked(evt);
        }
    });
    jListTickets.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jListTicketsValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(jListTickets);

    jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER);

    jPanel8.setLayout(new java.awt.BorderLayout());

    jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/cancel.png"))); // NOI18N
    jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
    jcmdCancel.setFocusPainted(false);
    jcmdCancel.setFocusable(false);
    jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdCancel.setRequestFocusEnabled(false);
    jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdCancelActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdCancel);

    jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
    jcmdOK.setEnabled(false);
    jcmdOK.setFocusPainted(false);
    jcmdOK.setFocusable(false);
    jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44));
    jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44));
    jcmdOK.setPreferredSize(new java.awt.Dimension(103, 44));
    jcmdOK.setRequestFocusEnabled(false);
    jcmdOK.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdOKActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdOK);

    jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END);

    jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH);

    getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

    jPanel2.setPreferredSize(new java.awt.Dimension(200, 250));
    jPanel2.setLayout(new java.awt.BorderLayout());
    jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH);

    getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END);

    setSize(new java.awt.Dimension(690, 511));
    setLocationRelativeTo(null);
}

From source file:org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement.java

public SQLComponent createComponent() {

    return new BaseSQLComponent(this) {

        private ValidState validVarName;
        private JRadioButton radioVal = new JRadioButton("Valeur");
        private JRadioButton radioFormule = new JRadioButton("Formule");

        private final JTextField textValeur = new JTextField();
        // private final ITextArea textFormule = new ITextArea();
        private final VariableTree treeVariable = new VariableTree();
        private final JTextField textNom = new JTextField();
        private final JLabel labelWarningBadVar = new JLabelWarning();
        private ElementComboBox comboSelSal;
        private EditFrame edit = null;
        private final SQLJavaEditor textFormule = new SQLJavaEditor(getMapTree());

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

            this.validVarName = null;
            this.textFormule.setEditable(false);

            // Arbre des variables
            JScrollPane sc = new JScrollPane(this.treeVariable);
            sc.setPreferredSize(new Dimension(150, sc.getPreferredSize().height));

            this.treeVariable.addMouseListener(new MouseAdapter() {
                public void mousePressed(final MouseEvent mE) {
                    if (mE.getButton() == MouseEvent.BUTTON3) {
                        JPopupMenu menuDroit = new JPopupMenu();

                        TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                mE.getPoint().y);

                        final Object obj = path.getLastPathComponent();

                        if ((obj == null) || !(obj instanceof VariableRowTreeNode)) {
                            return;
                        }/*  w  w w  .j a v  a2s.  c om*/

                        menuDroit.add(new AbstractAction("Editer") {
                            public void actionPerformed(ActionEvent e) {
                                if (edit == null) {
                                    edit = new EditFrame(getElement(), EditFrame.MODIFICATION);
                                }

                                System.err.println("Action performed");

                                if (obj != null) {
                                    System.err.println("Object not null --> " + obj.toString());
                                    if (obj instanceof VariableRowTreeNode) {
                                        System.err.println("Object VariableRowTreeNode");
                                        VariableRowTreeNode varNode = (VariableRowTreeNode) obj;

                                        edit.selectionId(varNode.getID(), 1);
                                        edit.setVisible(true);
                                    }
                                }
                            }
                        });
                        menuDroit.show((Component) mE.getSource(), mE.getPoint().x, mE.getPoint().y);
                    } else {
                        if (mE.getClickCount() == 2) {
                            TreePath path = treeVariable.getClosestPathForLocation(mE.getPoint().x,
                                    mE.getPoint().y);
                            Object obj = path.getLastPathComponent();

                            if (obj != null) {
                                if (obj instanceof FormuleTreeNode) {
                                    final FormuleTreeNode n = (FormuleTreeNode) obj;

                                    int start = textFormule.getSelectionStart();
                                    String tmp = textFormule.getText();
                                    textFormule.setText(tmp.substring(0, start) + n.getTextValue()
                                            + tmp.substring(start, tmp.length()));
                                }
                            }
                        }
                    }
                }
            });

            JPanel panelDroite = new JPanel();
            panelDroite.setLayout(new GridBagLayout());

            // Categorie
            JTextField textCategorie = new JTextField();
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy = 0;
            JLabel labelCategorie = new JLabel("Catgorie");
            panelDroite.add(labelCategorie, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(textCategorie, c);
            c.gridwidth = 1;

            // Nom
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridheight = 1;
            c.gridx = 1;
            c.gridy++;
            JLabel labelNom = new JLabel("Nom");
            panelDroite.add(labelNom, c);

            c.gridx++;
            c.weightx = 1;
            panelDroite.add(this.textNom, c);

            this.textNom.getDocument().addDocumentListener(new SimpleDocumentListener() {
                @Override
                public void update(DocumentEvent e) {
                    updateValidVarName();
                }
            });

            c.gridx++;
            c.weightx = 0;
            panelDroite.add(this.labelWarningBadVar, c);

            // Description
            JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
            ITextArea textInfos = new ITextArea();
            c.gridy++;
            c.gridx = 1;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(labelInfos, c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            c.weighty = 0;
            panelDroite.add(textInfos, c);

            // Valeur
            c.gridx = 1;
            c.gridy++;
            c.gridwidth = 1;
            c.weightx = 0;
            panelDroite.add(this.radioVal, c);

            c.gridx++;
            c.weightx = 1;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textValeur, c);

            c.gridwidth = 1;
            c.gridx = 1;
            c.gridy++;
            panelDroite.add(this.radioFormule, c);

            c.gridx++;
            c.weightx = 1;
            c.weighty = 1;
            c.fill = GridBagConstraints.BOTH;
            c.gridwidth = GridBagConstraints.REMAINDER;
            panelDroite.add(this.textFormule, c);
            c.gridwidth = 1;

            ButtonGroup group = new ButtonGroup();
            group.add(this.radioVal);
            group.add(this.radioFormule);

            this.radioVal.setSelected(true);
            setFormuleEnabled(false);

            this.radioVal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(false);
                }
            });
            this.radioFormule.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    setFormuleEnabled(true);
                }
            });

            c.gridy++;
            c.gridx = 1;
            c.weighty = 0;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;

            this.comboSelSal = new ElementComboBox(false);
            this.comboSelSal.init(getDirectory().getElement(SalarieSQLElement.class));

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

            JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sc, panelDroite);

            c.fill = GridBagConstraints.BOTH;
            c.gridx = 0;
            c.gridy = 0;
            c.weightx = 1;
            c.weighty = 1;
            this.add(split, c);

            this.addRequiredSQLObject(this.textNom, "NOM");
            this.addSQLObject(this.textValeur, "VALEUR");
            this.addSQLObject(this.textFormule, "FORMULE");
            this.addSQLObject(textCategorie, "CATEGORIE");
            this.addSQLObject(textInfos, "INFOS");

            this.comboSelSal.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    // TODO Auto-generated method stub
                    textFormule.setSalarieID(comboSelSal.getSelectedId());
                }
            });
        }

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

        private void setFormuleEnabled(boolean b) {

            if (b) {
                this.textValeur.setText("");
            } else {
                this.textFormule.setText("");
            }

            this.textValeur.setEditable(!b);
            this.textValeur.setEnabled(!b);
            this.textFormule.setEditable(b);
            this.textFormule.setEnabled(b);
            this.treeVariable.setEnabled(b);
            this.treeVariable.setEditable(b);
        }

        private void setValidVarName(ValidState s) {
            if (!s.equals(this.validVarName)) {
                this.validVarName = s;
                final boolean warningVisible = !s.isValid();
                if (warningVisible)
                    this.labelWarningBadVar.setText(s.getValidationText());
                this.labelWarningBadVar.setVisible(warningVisible);
                this.fireValidChange();
            }
        }

        private void updateValidVarName() {
            this.setValidVarName(this.computeValidVarName());
        }

        private ValidState computeValidVarName() {
            // on vrifie si la syntaxe de la variable est correct (chiffre lettre et _)
            final String varName = this.textNom.getText().trim();

            System.err.println("Verification de la validit du nom de la variable.");

            if (varName.length() == 0) {
                return VAR_NO_NAME;
            }

            // ne contient que des chiffre lettre et _ et ne commence pas par un chiffre
            if (!isJavaVar(varName)) {
                return VAR_NAME_NOT_CORRECT;
            }

            // on vrifie que la variable n'existe pas dja
            SQLSelect selAllVarName = new SQLSelect(getTable().getBase());

            selAllVarName.addSelect(VariablePayeSQLElement.this.getTable().getField("ID"));
            Where w = new Where(VariablePayeSQLElement.this.getTable().getField("NOM"), "=", varName);
            w = w.and(new Where(VariablePayeSQLElement.this.getTable().getKey(), "!=", getSelectedID()));
            selAllVarName.setWhere(w);

            String reqAllVarName = selAllVarName.asString();// + " AND '" + varName.trim() + "'
            // REGEXP VARIABLE_PAYE.NOM";
            Object[] objKeysRowName = ((List) getTable().getBase().getDataSource().execute(reqAllVarName,
                    new ArrayListHandler())).toArray();

            if (objKeysRowName.length > 0) {
                return VAR_ALREADY_EXIST;
            } else {

                // Impossible de crer une variable du meme nom qu'un champ du salarie
                if (isForbidden(varName))
                    return VAR_ALREADY_EXIST;

                this.textFormule.setVarAssign(varName);
                return ValidState.getTrueInstance();
            }
        }

        private boolean isJavaVar(String s) {
            if ((s.charAt(0) >= '0') && ((s.charAt(0) <= '9'))) {
                System.err.println("Erreur la variable commence par un chiffre!!");
                return false;
            } else {
                for (int i = 0; i < s.length(); i++) {

                    if (!(((s.charAt(i) >= '0') && (s.charAt(i) <= '9'))
                            || (s.charAt(i) >= 'a') && (s.charAt(i) <= 'z')
                            || (s.charAt(i) >= 'A') && (s.charAt(i) <= 'Z') || (s.charAt(i) == '_'))) {
                        System.err.println("Erreur la variable contient un caractere incorrect!!");
                        return false;
                    }
                }

                return (!CTokenMarker.getKeywords().isExisting(s));
            }
        }

        @Override
        public void select(SQLRowAccessor r) {

            super.select(r);
            // System.err.println("Select RowAccess -------> " + r.getID() + " For Object " +
            // this.hashCode());
            if (r != null) {
                if (r.getString("FORMULE").trim().length() == 0) {
                    this.radioVal.setSelected(true);
                    setFormuleEnabled(false);
                } else {
                    this.radioFormule.setSelected(true);
                    setFormuleEnabled(true);
                }

                this.textFormule.setVarAssign(r.getString("NOM"));
            }

            this.updateValidVarName();
        }
    };
}

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

private void fillRow4(JPanel host, GridBagConstraints c) {
    c.gridx = 0;/*from  w w  w  . j  a va 2  s.co m*/
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.NONE;
    this.directoryPathLabel = new JLabel("Directory Full Path");
    host.add(this.directoryPathLabel, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    host.add(Box.createHorizontalGlue(), c);
}

From source file:com.pingtel.sipviewer.SIPViewerFrame.java

protected void layoutComponents() {
    Container rootPane = this.getContentPane();

    // this is the vertical container to which all the
    // windows are added
    Container verticalContainer = new Container();
    verticalContainer.setLayout(new GridBagLayout());

    m_scrollPaneTimeIndex.setMinimumSize(new Dimension(150, 50));
    m_scrollPaneTimeIndexSecond.setMinimumSize(new Dimension(150, 50));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 0;//  w w w  .  j  a  v  a2 s  . co m
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = 1;

    verticalContainer.add(m_scrollPaneTimeIndex, gbc);
    gbc.gridx = 1;
    verticalContainer.add(m_scrollPane, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    verticalContainer.add(m_scrollPaneTimeIndexSecond, gbc);

    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    verticalContainer.add(m_scrollPaneSecond, gbc);

    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridwidth = 2;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    verticalContainer.add(m_infoPanel, gbc);

    rootPane.add(verticalContainer, BorderLayout.CENTER);
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/**
 * Builds and lays out the component displaying the various types.
 * //from  ww  w . ja v  a 2  s.com
 * @return See above.
 */
private JPanel buildType() {
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new GridBagLayout());
    // p.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(3, 3, 3, 3);
    List<SearchObject> nodes = model.getTypes();
    List<Integer> ctxNodes = null;
    SearchContext ctx = model.getSearchContext();
    if (ctx != null)
        ctxNodes = ctx.getType();

    SearchObject n;
    int m = nodes.size();
    JCheckBox box;
    c.weightx = 1.0;

    if (ctxNodes == null) {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);
            box.setSelected(true);
            p.add(box, c);
            if (i % 2 == 0)
                c.gridy++;
            types.put(n.getIndex(), box);
        }
    } else {
        for (int i = 0; i < m; i++) {
            n = nodes.get(i);
            box = new JCheckBox(n.getDescription());
            box.setBackground(UIUtilities.BACKGROUND_COLOR);
            box.setSelected(ctxNodes.contains(n.getIndex()));
            p.add(box, c);
            if (i % 2 == 0)
                c.gridy++;
            types.put(n.getIndex(), box);
        }
    }

    UIUtilities.setBoldTitledBorder(TYPE_TITLE, p);
    return p;
}