Example usage for javax.swing JComboBox JComboBox

List of usage examples for javax.swing JComboBox JComboBox

Introduction

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

Prototype

public JComboBox() 

Source Link

Document

Creates a JComboBox with a default data model.

Usage

From source file:com.floreantpos.ui.dialog.MiscTicketItemDialog.java

private void initComponents() {
    JPanel contentPane = new JPanel(new MigLayout("inset 0, fillx", "", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    setTitle(Messages.getString("MiscTicketItemDialog.4")); //$NON-NLS-1$
    setTitlePaneText(Messages.getString("MiscTicketItemDialog.4")); //$NON-NLS-1$

    JLabel lblName = new JLabel(Messages.getString("MiscTicketItemDialog.6")); //$NON-NLS-1$
    contentPane.add(lblName, "newline,alignx trailing"); //$NON-NLS-1$

    tfItemName = new FixedLengthTextField();
    tfItemName.setLength(120);//from  w ww . j  av a2  s . com
    contentPane.add(tfItemName, "grow, span, h 40"); //$NON-NLS-1$

    JLabel lblPrice = new JLabel(Messages.getString("MiscTicketItemDialog.9")); //$NON-NLS-1$
    contentPane.add(lblPrice, "newline,alignx trailing"); //$NON-NLS-1$

    tfItemPrice = new DoubleTextField();
    contentPane.add(tfItemPrice, "grow, w 120, h 40"); //$NON-NLS-1$

    lblTax = new JLabel(Messages.getString("MiscTicketItemDialog.12"));//$NON-NLS-2$
    contentPane.add(lblTax, "alignx trailing"); //$NON-NLS-1$ 

    PosComboRenderer comboRenderer = new PosComboRenderer();
    comboRenderer.setEnableDefaultValueShowing(false);

    cbTax = new JComboBox();
    cbTax.setRenderer(comboRenderer);
    contentPane.add(cbTax, "w 200!, h 40"); //$NON-NLS-1$

    contentPane.add(new JLabel(Messages.getString("MiscTicketItemDialog.15")), "alignx trailing"); //$NON-NLS-1$ //$NON-NLS-2$

    cbPrinterGroup = new JComboBox();
    cbPrinterGroup.setRenderer(comboRenderer);
    contentPane.add(cbPrinterGroup, "w 200!, h 40"); //$NON-NLS-1$

    QwertyKeyPad keyPad = new QwertyKeyPad();
    contentPane.add(keyPad, "newline, grow, span, gaptop 10"); //$NON-NLS-1$

    getContentPanel().add(contentPane);

    initData();
}

From source file:com.litt.core.security.license.gui.ConfigPanel.java

/**
 * Create the panel.//from ww  w .  ja  v  a 2  s  . c  o m
 */
public ConfigPanel(final Gui gui) {
    GridBagLayout gbl_configPanel = new GridBagLayout();
    gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
            Double.MIN_VALUE };
    this.setLayout(gbl_configPanel);

    JLabel label_18 = new JLabel("?");
    GridBagConstraints gbc_label_18 = new GridBagConstraints();
    gbc_label_18.insets = new Insets(0, 0, 5, 5);
    gbc_label_18.anchor = GridBagConstraints.EAST;
    gbc_label_18.gridx = 0;
    gbc_label_18.gridy = 0;
    this.add(label_18, gbc_label_18);

    comboBox_config = new JComboBox();
    comboBox_config.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                try {
                    LicenseConfig licenseConfig = (LicenseConfig) e.getItem();
                    File licenseFile = new File(licenseConfig.getLicenseFilePath());
                    currentLicenseConfig = licenseConfig;
                    loadLicense(licenseFile);
                    gui.setCurrentLicenseConfig(currentLicenseConfig);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            }
        }
    });
    GridBagConstraints gbc_comboBox_config = new GridBagConstraints();
    gbc_comboBox_config.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_config.gridx = 1;
    gbc_comboBox_config.gridy = 0;
    this.add(comboBox_config, gbc_comboBox_config);

    JButton button_3 = new JButton("?");
    button_3.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            try {
                comboBox_config.removeAllItems();

                File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                Document document = XmlUtils.readXml(configFile);
                Element rootE = document.getRootElement();
                List productList = rootE.elements();
                for (int i = 0; i < productList.size(); i++) {
                    Element productE = (Element) productList.get(i);
                    String productCode = productE.attributeValue("code");

                    List customerList = productE.elements();
                    for (int j = 0; j < customerList.size(); j++) {
                        Element customerE = (Element) customerList.get(j);
                        String customerCode = customerE.attributeValue("code");

                        LicenseConfig licenseConfig = new LicenseConfig();
                        licenseConfig.setProductCode(productCode);
                        licenseConfig.setCustomerCode(customerCode);
                        licenseConfig.setLicenseId(customerE.elementText("licenseId"));
                        licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense"));
                        licenseConfig.setRootFilePath(Gui.HOME_PATH);
                        licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode
                                + File.separator + customerCode + File.separator + "license.xml");
                        licenseConfig.setPriKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key");
                        licenseConfig.setPubKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key");
                        comboBox_config.addItem(licenseConfig);
                        if (i == 0 && j == 0) {
                            File licenseFile = new File(licenseConfig.getLicenseFilePath());
                            currentLicenseConfig = licenseConfig;
                            loadLicense(licenseFile);
                            gui.setCurrentLicenseConfig(currentLicenseConfig);

                            btnDelete.setEnabled(true);
                        }
                    }
                }

            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(self, e1.getMessage());
            }

        }
    });

    btnDelete = new JButton();
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentLicenseConfig != null) {
                try {
                    String productCode = currentLicenseConfig.getProductCode();
                    String customerCode = currentLicenseConfig.getCustomerCode();
                    //congfig.xml
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");
                    Document document = XmlUtils.readXml(configFile);

                    Element customerNode = (Element) document.selectSingleNode(
                            "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']");
                    if (customerNode != null) {
                        customerNode.detach();
                        XmlUtils.writeXml(configFile, document);
                    }
                    //                  
                    File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath());
                    if (licensePathFile.exists()) {
                        FileUtils.deleteDirectory(licensePathFile.getParentFile());
                    }

                    //comboboxitem
                    comboBox_config.removeItemAt(comboBox_config.getSelectedIndex());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if (comboBox_config.getItemCount() <= 0) {
                    btnDelete.setEnabled(false);
                }

            }
        }
    });
    btnDelete.setEnabled(false);
    btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png")));
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.insets = new Insets(0, 0, 5, 0);
    gbc_btnDelete.gridx = 2;
    gbc_btnDelete.gridy = 0;
    add(btnDelete, gbc_btnDelete);
    GridBagConstraints gbc_button_3 = new GridBagConstraints();
    gbc_button_3.insets = new Insets(0, 0, 5, 5);
    gbc_button_3.gridx = 1;
    gbc_button_3.gridy = 1;
    this.add(button_3, gbc_button_3);

    JLabel lblid = new JLabel("?ID");
    GridBagConstraints gbc_lblid = new GridBagConstraints();
    gbc_lblid.anchor = GridBagConstraints.EAST;
    gbc_lblid.insets = new Insets(0, 0, 5, 5);
    gbc_lblid.gridx = 0;
    gbc_lblid.gridy = 2;
    this.add(lblid, gbc_lblid);

    textField_licenseId = new JTextField();
    GridBagConstraints gbc_textField_licenseId = new GridBagConstraints();
    gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5);
    gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_licenseId.gridx = 1;
    gbc_textField_licenseId.gridy = 2;
    this.add(textField_licenseId, gbc_textField_licenseId);
    textField_licenseId.setColumns(10);

    JLabel label = new JLabel("?");
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.insets = new Insets(0, 0, 5, 5);
    gbc_label.gridx = 0;
    gbc_label.gridy = 3;
    add(label, gbc_label);

    comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray());
    GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints();
    gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_licenseType.gridx = 1;
    gbc_comboBox_licenseType.gridy = 3;
    add(comboBox_licenseType, gbc_comboBox_licenseType);

    JLabel label_23 = new JLabel("???");
    GridBagConstraints gbc_label_23 = new GridBagConstraints();
    gbc_label_23.anchor = GridBagConstraints.EAST;
    gbc_label_23.insets = new Insets(0, 0, 5, 5);
    gbc_label_23.gridx = 0;
    gbc_label_23.gridy = 4;
    this.add(label_23, gbc_label_23);

    textField_productName = new JTextField();
    GridBagConstraints gbc_textField_productName = new GridBagConstraints();
    gbc_textField_productName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_productName.gridx = 1;
    gbc_textField_productName.gridy = 4;
    this.add(textField_productName, gbc_textField_productName);
    textField_productName.setColumns(10);

    JLabel label_24 = new JLabel("???");
    GridBagConstraints gbc_label_24 = new GridBagConstraints();
    gbc_label_24.anchor = GridBagConstraints.EAST;
    gbc_label_24.insets = new Insets(0, 0, 5, 5);
    gbc_label_24.gridx = 0;
    gbc_label_24.gridy = 5;
    this.add(label_24, gbc_label_24);

    textField_companyName = new JTextField();
    GridBagConstraints gbc_textField_companyName = new GridBagConstraints();
    gbc_textField_companyName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_companyName.gridx = 1;
    gbc_textField_companyName.gridy = 5;
    this.add(textField_companyName, gbc_textField_companyName);
    textField_companyName.setColumns(10);

    JLabel label_25 = new JLabel("??");
    GridBagConstraints gbc_label_25 = new GridBagConstraints();
    gbc_label_25.anchor = GridBagConstraints.EAST;
    gbc_label_25.insets = new Insets(0, 0, 5, 5);
    gbc_label_25.gridx = 0;
    gbc_label_25.gridy = 6;
    this.add(label_25, gbc_label_25);

    textField_customerName = new JTextField();
    GridBagConstraints gbc_textField_customerName = new GridBagConstraints();
    gbc_textField_customerName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_customerName.gridx = 1;
    gbc_textField_customerName.gridy = 6;
    this.add(textField_customerName, gbc_textField_customerName);
    textField_customerName.setColumns(10);

    JLabel label_26 = new JLabel("");
    GridBagConstraints gbc_label_26 = new GridBagConstraints();
    gbc_label_26.anchor = GridBagConstraints.EAST;
    gbc_label_26.insets = new Insets(0, 0, 5, 5);
    gbc_label_26.gridx = 0;
    gbc_label_26.gridy = 7;
    this.add(label_26, gbc_label_26);

    textField_version = new JTextField();
    GridBagConstraints gbc_textField_version = new GridBagConstraints();
    gbc_textField_version.insets = new Insets(0, 0, 5, 5);
    gbc_textField_version.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_version.gridx = 1;
    gbc_textField_version.gridy = 7;
    this.add(textField_version, gbc_textField_version);
    textField_version.setColumns(10);

    JLabel label_27 = new JLabel("");
    GridBagConstraints gbc_label_27 = new GridBagConstraints();
    gbc_label_27.insets = new Insets(0, 0, 5, 5);
    gbc_label_27.gridx = 0;
    gbc_label_27.gridy = 8;
    this.add(label_27, gbc_label_27);

    datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    //datePicker_expiredDate.setTimePanleVisible(false);
    GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints();
    gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST;
    gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker_expiredDate.gridx = 1;
    gbc_datePicker_expiredDate.gridy = 8;
    this.add(datePicker_expiredDate, gbc_datePicker_expiredDate);

    JButton button_5 = new JButton("");
    button_5.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            if (currentLicenseConfig != null) {
                try {
                    File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath());
                    File licenseFile = new File(currentLicenseConfig.getLicenseFilePath());

                    //??
                    License license = new License();
                    license.setLicenseId(textField_licenseId.getText());
                    license.setLicenseType(
                            ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString());
                    license.setProductName(textField_productName.getText());
                    license.setCompanyName(textField_companyName.getText());
                    license.setCustomerName(textField_customerName.getText());
                    license.setVersion(Version.parseVersion(textField_version.getText()));
                    license.setCreateDate(new Date());
                    license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText()));

                    //????
                    DigitalSignatureTool utils = new DigitalSignatureTool("DSA");
                    utils.readPriKey(priKeyFile.getAbsolutePath()); //??
                    String signedData = utils.sign(license.toString()); //??????
                    license.setSignature(signedData);

                    LicenseManager.writeLicense(license, licenseFile);
                    //config.xml
                    String licenseContent = XmlUtils.readXml(licenseFile).asXML();
                    //DES
                    ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH);
                    licenseContent = security.encrypt(licenseContent);

                    txt_encryptContent.setText(licenseContent);
                    currentLicenseConfig.setEncryptedLicense(licenseContent);
                    System.out.println(licenseContent);
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                    XMLConfiguration config = new XMLConfiguration(configFile);
                    config.setAutoSave(true);

                    config.setProperty("product.customer.encryptedLicense", licenseContent);

                    //??zip?
                    File customerPath = licenseFile.getParentFile();
                    //???license?????
                    File licensePath = new File(customerPath.getParent(), "license");
                    if (!licensePath.exists() && !licensePath.isDirectory()) {
                        licensePath.mkdir();
                    } else {
                        FileUtils.cleanDirectory(licensePath);
                    }

                    //?
                    FileUtils.copyDirectory(customerPath, licensePath);
                    String currentTime = FormatDateTime.formatDateTimeNum(new Date());
                    ZipUtils.zip(licensePath, new File(licensePath.getParentFile(),
                            currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip"));

                    //license
                    FileUtils.deleteDirectory(licensePath);

                    JOptionPane.showMessageDialog(self, "??");
                } catch (Exception e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            } else {
                JOptionPane.showMessageDialog(self, "???");
            }
        }
    });
    GridBagConstraints gbc_button_5 = new GridBagConstraints();
    gbc_button_5.insets = new Insets(0, 0, 5, 5);
    gbc_button_5.gridx = 1;
    gbc_button_5.gridy = 9;
    this.add(button_5, gbc_button_5);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 1;
    gbc_scrollPane.gridy = 10;
    this.add(scrollPane, gbc_scrollPane);

    txt_encryptContent = new JTextArea();
    txt_encryptContent.setLineWrap(true);
    scrollPane.setViewportView(txt_encryptContent);

    //      txt_encryptContent = new JTextArea(20, 20);
    //      GridBagConstraints gbc_6 = new GridBagConstraints();
    //      gbc_6.gridx = 1;
    //      gbc_6.gridy = 10;
    //      this.add(txt_encryptContent, gbc_6);

}

From source file:components.ConversionPanel.java

ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
        setOpaque(true);/*from   w  ww  .j  a  v a 2s.co m*/
        setBackground(new Color(0, 255, 255));
    }
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    //Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);//seems to be a no-op --
    //aha -- it changes the value property but doesn't cause the result to
    //be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    //Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { //Populate it.
        unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    //Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    //Make the text field/slider group a fixed size
    //to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup = new JPanel() {
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
        }

        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        unitGroup.setOpaque(true);
        unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    //Create a subpanel so the combo box isn't too tall
    //and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        chooserPanel.setOpaque(true);
        chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    //Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
}

From source file:edu.virginia.iath.oxygenplugins.juel.JUELPluginMenu.java

public JUELPluginMenu(StandalonePluginWorkspace spw, LocalOptions ops) {
    super(name, true);
    ws = spw;/*from  w w w  . java  2  s  .co  m*/
    options = ops;

    // setup the options
    //options.readStorage();

    // Find names
    JMenuItem search = new JMenuItem("Find Name");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Name";

            final JTextField lastName = new JTextField("", 30);
            lastName.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL("http://juel.iath.virginia.edu/academical_db/people/find_people?term="
                                + lastName.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String name = cur.getString("label");
                            String id = String.format("P%05d", cur.getInt("value"));
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for last name, then choose a full name from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Last Name: "));
            addPanelInner.add(lastName);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find places
    search = new JMenuItem("Find Place");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Place";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/places/find_places?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("PL%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a place name, then choose one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find corporate bodies
    search = new JMenuItem("Find Corporate Body");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Corporate Body";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/corporate_bodies/find?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("CB%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a corporate body, then one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find Courses
    search = new JMenuItem("Find Course");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Course";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/courses/find?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("C%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a course, then choose one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);
}

From source file:com.actian.services.knime.core.operators.DeriveGroupNodeDialogPane.java

private void initComponents() {
    this.expression = new JTextArea(10, 20);
    expression.setWrapStyleWord(true);/*from   ww  w.j a  v a2  s  .  co  m*/
    expression.setFont(new Font("Monospaced", Font.PLAIN, 11));

    this.expressionPanel = new JScrollPane(expression);
    this.expressionPanel.setBorder(BorderFactory.createTitledBorder("Group Expressions"));

    functionPanel = new JPanel();
    functionPanel.setLayout(new GridLayout(0, 1, 0, 0));
    functionPanel.setBorder(BorderFactory.createTitledBorder("Available Aggregate Functions"));

    fcomboBox = new JComboBox();
    fcomboBox.setMaximumRowCount(10);
    fcomboBox.setModel(new DefaultComboBoxModel(new String[] { "Function - Description" }));
    fcomboBox.setFont(new Font("Monospaced", Font.PLAIN, 10));
    functionPanel.add(fcomboBox);

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup()
            .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addContainerGap().addComponent(columnSelect,
                                    GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addGap(7).addComponent(expressionPanel,
                                    GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addContainerGap()
                            .addComponent(functionPanel, GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)))
            .addGap(7)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addGap(5)
                    .addComponent(expressionPanel, GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(functionPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(columnSelect, GroupLayout.PREFERRED_SIZE, 248, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    setLayout(groupLayout);
}

From source file:ca.sfu.federation.viewer.propertysheet.PlanePropertySheet.java

/** 
 * ParametricModelSheet constructors.//from   w  ww. j  av a  2  s. c  o m
 */
public PlanePropertySheet() {
    lblINamedObject = new JLabel();
    lblName = new JLabel();
    lblDescription = new JLabel();
    jtfClass = new JTextField();
    jtfName = new JTextField();
    jtfCanonicalName = new JTextField();
    lblCanonicalName = new JLabel();
    lblClass = new JLabel();
    jtfDescription = new JTextField();
    lblParentContext = new JLabel();
    jtfParentContext = new JTextField();
    lblX = new JLabel();
    lblY = new JLabel();
    lblZ = new JLabel();
    jtfX = new JTextField();
    jtfY = new JTextField();
    jtfZ = new JTextField();
    lblUpdateMethod = new JLabel();
    jcbUpdateMethod = new JComboBox();
    jScrollPane1 = new JScrollPane();

    lblINamedObject.setFont(new java.awt.Font("Tahoma", 0, 14));
    lblINamedObject.setText("jLabel1");
    lblName.setText("Name");
    lblDescription.setText("Description");
    lblClass.setText("Class");
    lblCanonicalName.setText("Canonical Name");
    lblParentContext.setText("Parent Context");
    lblX.setText("X Coordinate");
    lblY.setText("Y Coordinate");
    lblZ.setText("Z Coordinate");
    lblUpdateMethod.setText("Update Method");

    this.jtfCanonicalName.setEditable(false);
    this.jtfClass.setEditable(false);
    this.jtfParentContext.setEditable(false);

    jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                            layout.createSequentialGroup().addContainerGap()
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    301, Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, lblINamedObject)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, layout
                                                    .createSequentialGroup().add(layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(lblCanonicalName).add(
                                                                    lblClass)
                                                            .add(lblName).add(
                                                                    lblDescription)
                                                            .add(lblParentContext).add(lblX).add(lblZ).add(lblY)
                                                            .add(lblUpdateMethod))
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(jcbUpdateMethod, 0, 221, Short.MAX_VALUE)
                                                            .add(jtfName,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfClass,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfDescription,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                                    layout.createSequentialGroup()
                                                                            .addPreferredGap(
                                                                                    org.jdesktop.layout.LayoutStyle.RELATED)
                                                                            .add(jtfCanonicalName,
                                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                                    221, Short.MAX_VALUE))
                                                            .add(jtfParentContext,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfX,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfY,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfZ,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE))))
                                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap().add(lblINamedObject)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblClass))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblName))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblCanonicalName)
                            .add(jtfCanonicalName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblDescription).add(jtfDescription,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblParentContext)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(lblX).add(
                            jtfX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblY))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfZ, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblZ))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jcbUpdateMethod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblUpdateMethod))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addContainerGap()));

    // set field values
    this.setValues();

    // add action listeners
    jtfName.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfNameActionListener(evt);
        }
    });
    jtfDescription.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfDescriptionActionListener(evt);
        }
    });
    jtfX.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfXActionListener(evt);
        }
    });
    jtfY.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfYActionListener(evt);
        }
    });
    jtfZ.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfZActionListener(evt);
        }
    });
    jcbUpdateMethod.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbUpdateMethodActionListener(evt);
        }
    });

}

From source file:utybo.easypastebin.windows.MainWindow.java

/**
 * Creates the window/*www. j  a v a  2s  . c  om*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public MainWindow() {
    EasyPastebin.LOGGER.log("Initializing the window", SinkJLevel.INFO);
    setTitle("EasyPastebin");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 664, 431);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane, BorderLayout.CENTER);

    JPanel main = new JPanel();
    tabbedPane.addTab("EasyPastebin", null, main, null);
    main.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(62, 39, 312, 132);
    main.add(scrollPane);

    pasteContent = new JTextArea();
    pasteContent.setFont(new Font("Monospaced", Font.PLAIN, 11));
    pasteContent.setWrapStyleWord(true);
    pasteContent.setLineWrap(true);
    pasteContent.setToolTipText("Put your paste here!");
    scrollPane.setViewportView(pasteContent);

    JLabel titleLabel = new JLabel("Title :");
    titleLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
    titleLabel.setBounds(10, 11, 42, 21);
    main.add(titleLabel);

    pasteTitle = new JTextField();
    pasteTitle.setBounds(62, 12, 312, 20);
    main.add(pasteTitle);
    pasteTitle.setColumns(10);

    JLabel lblPaste = new JLabel("Paste :");
    lblPaste.setForeground(Color.RED);
    lblPaste.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblPaste.setBounds(10, 85, 53, 21);
    main.add(lblPaste);

    pasteExpireDate = new JComboBox();
    pasteExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    pasteExpireDate.setModel(new DefaultComboBoxModel(EnumExpireDate.values()));
    pasteExpireDate.setBounds(468, 12, 155, 21);
    main.add(pasteExpireDate);

    JLabel lblExpireDate = new JLabel("Expire Date :");
    lblExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblExpireDate.setBounds(384, 14, 81, 14);
    main.add(lblExpireDate);

    JLabel lblfieldsInRed = new JLabel("(Fields in red are required)");
    lblfieldsInRed.setBounds(72, 182, 302, 14);
    main.add(lblfieldsInRed);

    btnSubmit = new JButton("Submit!");
    btnSubmit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            EasyPastebin.LOGGER.log("Starting Submit script", SinkJLevel.INFO);
            btnSubmit.setEnabled(false);
            btnSubmit.setText("Please wait...");

            boolean success = true;
            String paste = pasteContent.getText();
            String title = pasteTitle.getText();
            EnumExpireDate expireDate = (EnumExpireDate) pasteExpireDate.getSelectedItem();

            if (paste.equals("") || paste.equals(" ") || paste.equals(null)) {
                pastebinUrl.setText("ERROR");
                JOptionPane.showMessageDialog(null, "You cannot send empty pastes!",
                        "Error while processing paste", JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    EasyPastebin.LOGGER.log("Setting options", SinkJLevel.INFO);
                    Map map = new HashMap<String, String>();
                    map.put("api_dev_key", HttpHelper.API_KEY);
                    map.put("api_option", "paste");
                    map.put("api_paste_code", paste);
                    if (!(expireDate.equals(null) || expireDate.equals(EnumExpireDate.NEVER)))
                        map.put("api_paste_expire_date", expireDate.getRawName());
                    if (!(title.equals("") || title.equals(" ") || title.equals(null)))
                        map.put("api_paste_name", title);

                    EasyPastebin.LOGGER.log("Sending paste", SinkJLevel.INFO);
                    String actionResult = HttpHelper.sendPost("http://pastebin.com/api/api_post.php", map)
                            .asString();
                    EasyPastebin.LOGGER.log("Paste sent, checking output", SinkJLevel.INFO);
                    // Exception handlers
                    if (actionResult.equals("Bad API request, invalid api_option")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect Pastebin option!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_dev_key")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect dev key! Try again with a more recent version!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, IP blocked")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Your IP is blocked!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 25 unlisted pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 10 private pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, api_paste_code was empty")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, maximum paste file size exceeded")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Your paste is too big!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_expire_date")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid expire date!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_private")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid privacy value!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_format")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid format!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    // END

                    // Starting display stuff
                    if (success == false) {
                        EasyPastebin.LOGGER.log("Submit script failed : success == false", SinkJLevel.ERROR);
                        pastebinUrl.setText("ERROR");
                    }
                    if (success == true) {
                        EasyPastebin.LOGGER.log("Paste sent! Starting display script!", SinkJLevel.INFO);
                        pastebinUrl.setText(actionResult);
                        JOptionPane.showMessageDialog(null, "Paste successfully sent!", "Done!",
                                JOptionPane.INFORMATION_MESSAGE);
                        EasyPastebin.LOGGER.log("Display script finished! Paste URL is : " + actionResult,
                                SinkJLevel.INFO);
                    }

                } catch (ClientProtocolException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (IOException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (MissingParamException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e
                            + "! This is a severe programming error! Try again with a more recent version!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                }
            }

            EasyPastebin.LOGGER.log("Re-enabling the Submit button ", SinkJLevel.INFO);
            btnSubmit.setEnabled(true);
            btnSubmit.setText("Submit another paste!");
            EasyPastebin.LOGGER.log("Finished submit script! Success : " + success, SinkJLevel.INFO);
        }
    });
    btnSubmit.setBounds(386, 45, 237, 44);
    main.add(btnSubmit);

    pastebinUrl = new JTextField();
    pastebinUrl.setText("The paste's URL will be shown here!");
    pastebinUrl.setEditable(false);
    pastebinUrl.setBounds(384, 198, 239, 32);
    main.add(pastebinUrl);
    pastebinUrl.setColumns(10);

    JPanel about = new JPanel();
    tabbedPane.addTab("About", null, about, null);

    JLabel label = new JLabel("EasyPastebin");
    label.setBounds(12, 12, 623, 39);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Dialog", Font.PLAIN, 25));

    JLabel lblTheEasiestWay = new JLabel("The easiest way to use Pastebin.com");
    lblTheEasiestWay.setBounds(12, 63, 623, 32);
    lblTheEasiestWay.setFont(new Font("Dialog", Font.PLAIN, 16));
    lblTheEasiestWay.setHorizontalAlignment(SwingConstants.CENTER);
    about.setLayout(null);
    about.add(label);
    about.add(lblTheEasiestWay);

    JButton btnForkM = new JButton("Fork me on Github!");
    btnForkM.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("https://github.com/utybo/EasyPastebin");
        }
    });
    btnForkM.setBounds(12, 117, 623, 25);
    about.add(btnForkM);

    JButton btnCheckOutUtybos = new JButton("Check out utybo's projects!");
    btnCheckOutUtybos.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://utybo.github.io/");
        }
    });
    btnCheckOutUtybos.setBounds(12, 154, 623, 25);
    about.add(btnCheckOutUtybos);

    JButton btnGoToPastebincom = new JButton("Go to Pastebin.com!");
    btnGoToPastebincom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://www.pastebin.com");
        }
    });
    btnGoToPastebincom.setBounds(12, 191, 623, 25);
    about.add(btnGoToPastebincom);

    JLabel lblcUtybo = new JLabel(
            "This soft was made by utybo. It uses Apache's libraries for the interaction with Pastebin's API");
    lblcUtybo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblcUtybo.setHorizontalAlignment(SwingConstants.CENTER);
    lblcUtybo.setBounds(12, 324, 623, 15);
    about.add(lblcUtybo);

    JLabel lblClickMeTo = new JLabel("Click me to go to Apache's licence official website");
    lblClickMeTo.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            goToUrl("http://www.apache.org/licenses/LICENSE-2.0");
        }
    });
    lblClickMeTo.setHorizontalAlignment(SwingConstants.CENTER);
    lblClickMeTo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblClickMeTo.setBounds(12, 342, 623, 15);
    about.add(lblClickMeTo);

    setVisible(true);

    EasyPastebin.LOGGER.log("Done!", SinkJLevel.INFO);
}

From source file:ca.sfu.federation.viewer.propertysheet.LinePropertySheet.java

/**
 * ParametricModelSheet constructor.//from w  w  w.j  ava2s.  c  o m
 */
public LinePropertySheet() {
    lblINamedObject = new JLabel();
    lblName = new JLabel();
    lblDescription = new JLabel();
    jtfClass = new JTextField();
    jtfName = new JTextField();
    jtfCanonicalName = new JTextField();
    lblCanonicalName = new JLabel();
    lblClass = new JLabel();
    jtfDescription = new JTextField();
    lblParentContext = new JLabel();
    jtfParentContext = new JTextField();
    lblStartPoint = new JLabel();
    lblMidPoint = new JLabel();
    lblEndPoint = new JLabel();
    jtfStartPoint = new JTextField();
    jtfMidPoint = new JTextField();
    jtfEndPoint = new JTextField();
    lblUpdateMethod = new JLabel();
    jcbUpdateMethod = new JComboBox();
    jspUpdateMethodInputs = new JPanel();
    lblLength = new JLabel();
    jtfLength = new JTextField();
    lblDirection = new javax.swing.JLabel();
    jtfDirection = new javax.swing.JTextField();

    lblINamedObject.setFont(new java.awt.Font("Tahoma", 0, 14));
    lblINamedObject.setText("jLabel1");
    lblName.setText("Name");
    lblDescription.setText("Description");
    lblCanonicalName.setText("Canonical Name");
    lblClass.setText("Class");
    lblParentContext.setText("Parent Context");
    lblStartPoint.setText("StartPoint");
    lblMidPoint.setText("MidPoint");
    lblEndPoint.setText("EndPoint");
    lblUpdateMethod.setText("Update Method");
    lblLength.setText("Length");
    lblDirection.setText("Direction");

    jtfClass.setEditable(false);
    jtfCanonicalName.setEditable(false);
    jtfParentContext.setEditable(false);
    jtfStartPoint.setEditable(false);
    jtfMidPoint.setEditable(false);
    jtfEndPoint.setEditable(false);
    jtfLength.setEditable(false);
    jtfDirection.setEditable(false);

    jspUpdateMethodInputs.setLayout(new BorderLayout());
    jspUpdateMethodInputs.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout
            .createSequentialGroup().addContainerGap()
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jspUpdateMethodInputs,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
                    .add(lblINamedObject)
                    .add(layout.createSequentialGroup()
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(lblCanonicalName).add(lblClass).add(lblName).add(lblDescription)
                                    .add(lblParentContext).add(lblStartPoint).add(lblEndPoint).add(lblMidPoint)
                                    .add(lblDirection).add(lblLength))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jtfName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfClass, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfDescription, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                            layout.createSequentialGroup()
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(jtfCanonicalName,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                                            Short.MAX_VALUE))
                                    .add(jtfParentContext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfStartPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfMidPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfEndPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfLength, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfDirection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                            .add(lblUpdateMethod).add(6, 6, 6).add(jcbUpdateMethod, 0, 221, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap().add(lblINamedObject)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblClass))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblName))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblCanonicalName)
                            .add(jtfCanonicalName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblDescription).add(jtfDescription,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblParentContext)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(lblStartPoint)
                            .add(jtfStartPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfMidPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblMidPoint))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfEndPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblEndPoint))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfLength, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblLength))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfDirection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblDirection))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jcbUpdateMethod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblUpdateMethod))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jspUpdateMethodInputs,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
                    .addContainerGap()));

    // disable non editable fields
    this.jtfCanonicalName.setEditable(false);
    this.jtfClass.setEditable(false);
    this.jtfParentContext.setEditable(false);

    // set field values
    this.setValues();

    // set action listeners
    jtfName.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfNameActionListener(evt);
        }
    });
    jtfDescription.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfDescriptionActionListener(evt);
        }
    });
    jcbUpdateMethod.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbUpdateMethodActionListener(evt);
        }
    });

}

From source file:pdi.HistogramaRGB.java

private JPanel criaPainel() {
    JPanel panel = new JPanel();
    JComboBox Jbox = new JComboBox();
    JButton histEqual = new JButton("Equalizar Histograma");
    panel.add(new JCheckBox(new HistogramaRGB.exibeAcao(0)));
    panel.add(new JCheckBox(new HistogramaRGB.exibeAcao(1)));
    panel.add(new JCheckBox(new HistogramaRGB.exibeAcao(2)));
    panel.add(histEqual);//from   www. j a v a  2  s .com
    panel.add(Jbox);
    return panel;
}

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

public SimpleChart(final String title, final StreamConnection connection) {
    super(title);

    dataset = new DynamicTimeSeriesCollection(SERIES, COUNT, new Second());
    dataset.setTimeBase(new Second(0, 0, 0, 1, 1, Calendar.getInstance().get(Calendar.YEAR)));

    // Init./*from  ww w .  ja v a  2  s  .  c  om*/
    //        for (int i = 0; i < SERIES; i++){
    //            dataset.addSeries(new float[]{0}, i, "Serie " + (i+1));
    //        }
    dataset.addSeries(new float[] { 0, 0, 0 }, 0, "Raw");
    dataset.addSeries(new float[] { 0, 0, 0 }, 1, "Software");
    dataset.addSeries(new float[] { 0, 0, 0 }, 2, "Hardware");

    this.connection = connection;

    // connection.setStreamReader(new FixedStreamReader(1));

    JFreeChart chart = createChart(dataset);

    final JButton run = new JButton(START);
    run.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            String cmd = e.getActionCommand();
            JButton source = (JButton) e.getSource();

            try {

                if (cmd.equals(START)) {
                    connection.addListener(SimpleChart.this);
                    if (!connection.isConnected())
                        connection.connect();

                    source.setText(STOP);
                    source.setActionCommand(STOP);
                } else {
                    connection.removeListener(SimpleChart.this);
                    source.setText(START);
                    source.setActionCommand(START);
                }

            } catch (ConnectionException e1) {
                e1.printStackTrace();
            }

        }
    });

    final JComboBox combo = new JComboBox();

    if (connection instanceof UsbConnection) {

        Collection<String> portNames = UsbConnection.listAvailablePortNames();
        for (String name : portNames) {
            combo.addItem(name);
        }

    }

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            Object selectedItem = combo.getSelectedItem();

        }
    });

    this.add(new ChartPanel(chart), BorderLayout.CENTER);
    JPanel btnPanel = new JPanel(new FlowLayout());
    btnPanel.add(run);
    btnPanel.add(combo);
    this.add(btnPanel, BorderLayout.SOUTH);

}