Example usage for javax.swing DefaultComboBoxModel DefaultComboBoxModel

List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel

Introduction

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

Prototype

public DefaultComboBoxModel(Vector<E> v) 

Source Link

Document

Constructs a DefaultComboBoxModel object initialized with a vector.

Usage

From source file:gtu._work.ui.SaveFileToPropertiesUI.java

private void initGUI() {
    try {//from  w  w w .  j  a v a 2s  .  c om
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        this.setTitle("save file to properties");
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("load", null, jPanel1, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel1.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        textArea = new JTextArea();
                        jScrollPane2.setViewportView(textArea);
                    }
                }
                {
                    jPanel2 = new JPanel();
                    jPanel1.add(jPanel2, BorderLayout.NORTH);
                    jPanel2.setPreferredSize(new java.awt.Dimension(400, 40));
                    {
                        addPropsFile = new JButton();
                        jPanel2.add(addPropsFile);
                        addPropsFile.setText("load properties from file");
                        addPropsFile.setPreferredSize(new java.awt.Dimension(234, 30));
                        addPropsFile.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog()
                                        .getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("file is not correct!", "ERROR");
                                    return;
                                }
                                try {
                                    props.load(new InputStreamReader(new FileInputStream(file),
                                            (String) openUnknowFilecharSet.getSelectedItem()));
                                    reloadPropertiesTable();
                                } catch (Exception e) {
                                    JCommonUtil.handleException(e);
                                }
                            }
                        });
                    }
                    {
                        openFile = new JButton();
                        jPanel2.add(openFile);
                        openFile.setText("open unknow file");
                        openFile.setPreferredSize(new java.awt.Dimension(204, 30));
                        openFile.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog()
                                        .getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("file is not correct!", "ERROR");
                                    return;
                                }
                                try {
                                    String encode = (String) openUnknowFilecharSet.getSelectedItem();
                                    BufferedReader reader = new BufferedReader(
                                            new InputStreamReader(new FileInputStream(file), encode));
                                    StringBuilder sb = new StringBuilder();
                                    for (String line = null; (line = reader.readLine()) != null;) {
                                        sb.append(line + "\n");
                                    }
                                    reader.close();
                                    textArea.setText(textArea.getText() + "\n" + sb);
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }
                        });
                    }
                    {
                        ComboBoxModel openUnknowFilecharSetModel = new DefaultComboBoxModel(
                                new String[] { "BIG5", "UTF8" });
                        openUnknowFilecharSet = new JComboBox();
                        jPanel2.add(openUnknowFilecharSet);
                        openUnknowFilecharSet.setModel(openUnknowFilecharSetModel);
                        openUnknowFilecharSet.setPreferredSize(new java.awt.Dimension(73, 24));
                    }
                    {
                        appendTextAreaToProps = new JButton();
                        jPanel2.add(appendTextAreaToProps);
                        appendTextAreaToProps.setText("append textarea to properties");
                        appendTextAreaToProps.setPreferredSize(new java.awt.Dimension(227, 30));
                        appendTextAreaToProps.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                if (StringUtils.isBlank(textArea.getText())) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("textArea is empty", "ERROR");
                                    return;
                                }
                                try {
                                    BufferedReader reader = new BufferedReader(
                                            new StringReader(textArea.getText()));
                                    int pos = -1;
                                    String key = null;
                                    String value = null;
                                    for (String line = null; (line = reader.readLine()) != null;) {
                                        if ((pos = line.lastIndexOf("=")) != -1) {
                                            key = line.substring(0, pos);
                                            value = line.substring(pos + 1);
                                            props.put(key, value);
                                        }
                                    }
                                    reader.close();
                                    JOptionPaneUtil.newInstance().iconInformationMessage()
                                            .showMessageDialog("append success!", "SUCCESS");
                                    reloadPropertiesTable();
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }
                        });
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("props edit", null, jPanel3, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel3.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(629, 361));
                    {
                        TableModel propsTableModel = new DefaultTableModel();
                        propsTable = new JTable();
                        jScrollPane1.setViewportView(propsTable);
                        propsTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                if (propsTable.getRowCount() == 0) {
                                    return;
                                }
                                int rowPos = JTableUtil.newInstance(propsTable).getSelectedRow();
                                Object key = propsTable.getValueAt(rowPos, 0);
                                Object value = propsTable.getValueAt(rowPos, 1);

                                JMenuItem insertRowItem = JTableUtil.newInstance(propsTable)
                                        .jMenuItem_addRow(false, null);
                                insertRowItem.setText("inert row...");

                                String rowInfo = "delete row : [" + key + "] = [" + value + "]";
                                JMenuItem delRowItem = JTableUtil.newInstance(propsTable)
                                        .jMenuItem_removeRow("are you sure remove row : \n" + rowInfo);
                                delRowItem.setText(rowInfo);

                                JPopupMenuUtil.newInstance(propsTable).applyEvent(evt)
                                        .addJMenuItem(insertRowItem, delRowItem).show();
                            }
                        });
                        propsTable.setModel(propsTableModel);
                        JTableUtil.defaultSetting(propsTable);
                    }
                }
                {
                    jPanel4 = new JPanel();
                    jPanel3.add(jPanel4, BorderLayout.SOUTH);
                    jPanel4.setPreferredSize(new java.awt.Dimension(629, 45));
                    {
                        clearProps = new JButton();
                        jPanel4.add(clearProps);
                        clearProps.setText("clear properties");
                        clearProps.setPreferredSize(new java.awt.Dimension(182, 36));
                        clearProps.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                props.clear();
                                reloadPropertiesTable();
                            }
                        });
                    }
                    {
                        savePropsToFile = new JButton();
                        jPanel4.add(savePropsToFile);
                        savePropsToFile.setText("save properties to file");
                        savePropsToFile.setPreferredSize(new java.awt.Dimension(182, 36));
                        savePropsToFile.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog()
                                        .getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("file is not correct!", "ERROR");
                                    return;
                                }
                                try {
                                    props.clear();
                                    DefaultTableModel model = (DefaultTableModel) propsTable.getModel();
                                    Object key = null;
                                    Object value = null;
                                    for (int ii = 0; ii < model.getRowCount(); ii++) {
                                        key = model.getValueAt(ii, 0);
                                        value = model.getValueAt(ii, 1);
                                        props.put(key, value);
                                    }
                                    props.store(new FileOutputStream(file),
                                            SaveFileToPropertiesUI.class.getSimpleName());
                                    JOptionPaneUtil.newInstance().iconInformationMessage()
                                            .showMessageDialog("save completed!\n" + file, "SUCCESS");
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            }
                        });
                    }
                }
            }
        }
        pack();
        this.setSize(798, 505);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Java2sAutoTextField.java

public void setDataList(java.util.List list) {
        autoTextFieldEditor.getAutoTextFieldEditor().setDataList(list);
        setModel(new DefaultComboBoxModel(list.toArray()));
    }/*w w  w .ja  v  a 2s. c  o  m*/

From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java

public void reloadModel() {
    final SwingWorker worker = new SwingWorker(this) {
        public Object doNonUILogic() {
            try {
                // This might take a while. Contructor should be running as SwingWorker
                JAXRClient client = RegistryBrowser.getInstance().getClient();
                Connection connection = client.getConnection();
                RegistryService service = connection.getRegistryService();
                dqm = (it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl) service
                        .getDeclarativeQueryManager();
                lcm = (it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl) service
                        .getBusinessLifeCycleManager();
                processConfiguration();//from   w w w.j  a va  2s.  c o m
                // model!!!
            } catch (JAXRException e) {
                throw new UndeclaredThrowableException(e);
            }
            return null;
        }

        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void doUIUpdateLogic() {
            try {
                selectQueryCombo.setModel(new DefaultComboBoxModel(getQueryNames()));
                if (queries.size() > 0) {
                    setQuery(queries.get(0));
                }
            } catch (JAXRException e) {
                throw new UndeclaredThrowableException(e);
            }
        }
    };
    worker.start();
}

From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java

public TableCellEditor getCellEditor(int row, int column) {
    SpreadSheetModel model = (SpreadSheetModel) getModel();
    Field field = model.getFieldInColumn(column + 1);
    GraphicNode node = model.getNode(row);
    if (field != null && (field.isDynamicOptions() || field.hasFilter())) {
        return new SimpleComboBoxEditor(new DefaultComboBoxModel(field.getOptions(node.getNode().getImpl())));
    } else {/*  w  ww.  j  av a 2  s . c o m*/
        return super.getCellEditor(row, column);
    }
}

From source file:techtonic.Onview.java

/**
 * Creates new form Onview//w  w  w  .ja v  a 2 s.c o m
 */
public Onview() {
    initComponents();
    loadDisplayScreen();
    jcbX_Axis.setModel(new DefaultComboBoxModel(new String[] {}));
    jcbX_Axis.setEnabled(false);
    jcbY_Axis.setModel(new DefaultComboBoxModel(new String[] {}));
    jcbY_Axis.setEnabled(false);
    setResizable(false);
}

From source file:hpssim.grafica.HPSsim.java

private void comboBoxSchedulerActionPerformed(ActionEvent e) {
    if (comboBoxScheduler.getSelectedIndex() > 0) {
        comboBoxQueue.setModel(new DefaultComboBoxModel<>(new String[] { "Red Black Tree", }));
        textFieldTimeSlice.setEnabled(false);
    } else {//from  www.j a v a 2s  . c  om
        comboBoxQueue.setModel(new DefaultComboBoxModel<>(new String[] { "FIFO", "Highest Priority First",
                "Shortest Job First", "Round Robin", "Random Queue" }));
        textFieldTimeSlice.setEnabled(true);
    }
}

From source file:io.github.jeddict.jpa.modeler.source.generator.ui.GenerateCodeDialog.java

private void initLayer() {
    setCompleteApplicationCompVisibility(false);

    configPane.removeAll();/*from  w  w  w  . j ava 2  s.  c  o  m*/
    configPane.setVisible(false);

    infoLabel.setText("");
    businessLayerCombo.setModel(
            new DefaultComboBoxModel(Generator.getBusinessService(isMicroservice() || isGateway()).toArray()));
    controllerLayerCombo
            .setModel(new DefaultComboBoxModel(new Object[] { new TechContext(DefaultControllerLayer.class) }));
    viewerLayerCombo
            .setModel(new DefaultComboBoxModel(new Object[] { new TechContext(DefaultViewerLayer.class) }));
    businessLayerCombo.setEnabled(true);
    controllerLayerCombo.setEnabled(false);
    viewerLayerCombo.setEnabled(false);

    TechContext businessContext = Generator
            .get(technologyPref.get(BUSINESS.name(), DefaultBusinessLayer.class.getSimpleName()));
    TechContext controllerContext = Generator
            .get(technologyPref.get(CONTROLLER.name(), DefaultControllerLayer.class.getSimpleName()));
    TechContext viewerContext = Generator
            .get(technologyPref.get(VIEWER.name(), DefaultViewerLayer.class.getSimpleName()));

    SwingUtilities.invokeLater(() -> {

        if (businessContext != null) {
            businessLayerCombo.getModel().setSelectedItem(businessContext);
            if (businessContext.isValid() && controllerContext != null) {
                controllerLayerCombo.getModel().setSelectedItem(controllerContext);
                if (controllerContext.isValid() && viewerContext != null) {
                    viewerLayerCombo.getModel().setSelectedItem(viewerContext);
                }
            }
        }
    });
}

From source file:autoGui.RegisterPagePanel.java

RegisterPagePanel(JFrame parent, MouseAdapter backHandler) {
    parent.getContentPane().add(RegisterPage, "name_22846752421143");
    RegisterPage.setLayout(null);/*w  w w. j a  va 2s  .  c o m*/
    //System.out.println(parent.getContentPane());
    RegisterPage.setBounds(100, 100, 1036, 608);

    email = new JTextField();
    email.setBounds(642, 87, 116, 22);
    RegisterPage.add(email);
    email.setColumns(10);

    JLabel lblEmail = new JLabel("Email*");
    lblEmail.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblEmail.setBounds(506, 89, 56, 16);
    RegisterPage.add(lblEmail);

    JLabel lblNewLabel = new JLabel("Password*");
    lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblNewLabel.setBounds(506, 132, 71, 16);
    RegisterPage.add(lblNewLabel);

    JLabel lblFirstName = new JLabel("First Name*");
    lblFirstName.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblFirstName.setBounds(141, 87, 88, 16);
    RegisterPage.add(lblFirstName);

    firstName = new JTextField();
    firstName.setBounds(241, 85, 142, 22);
    RegisterPage.add(firstName);
    firstName.setColumns(10);

    JLabel lblNewLabel_1 = new JLabel("Middle Name");
    lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblNewLabel_1.setBounds(141, 132, 88, 16);
    RegisterPage.add(lblNewLabel_1);

    middleName = new JTextField();
    middleName.setBounds(241, 129, 142, 22);
    RegisterPage.add(middleName);
    middleName.setColumns(10);

    JLabel lblNewLabel_2 = new JLabel("Last Name*");
    lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblNewLabel_2.setBounds(141, 174, 88, 16);
    RegisterPage.add(lblNewLabel_2);

    lastName = new JTextField();
    lastName.setBounds(241, 172, 142, 22);
    RegisterPage.add(lastName);
    lastName.setColumns(10);

    JLabel lblPersonalInformation = new JLabel("Personal Information");
    lblPersonalInformation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    lblPersonalInformation.setBounds(86, 33, 159, 27);
    RegisterPage.add(lblPersonalInformation);

    JLabel lblContactInformation = new JLabel("Contact Information");
    lblContactInformation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    lblContactInformation.setBounds(459, 33, 175, 27);
    RegisterPage.add(lblContactInformation);

    JLabel lblPhoneNumber = new JLabel("Phone*");
    lblPhoneNumber.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblPhoneNumber.setBounds(506, 217, 71, 16);
    RegisterPage.add(lblPhoneNumber);

    phone = new JTextField();
    phone.setBounds(642, 215, 116, 22);
    RegisterPage.add(phone);
    phone.setColumns(10);

    password = new JPasswordField();
    password.setBounds(642, 130, 116, 22);
    RegisterPage.add(password);

    JButton btnBack_5 = new JButton("Back");
    btnBack_5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });

    btnBack_5.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (lastPage == 6) {
                lastPage = 4;

            }
            RegisterPage.setVisible(false);
            parent.getContentPane().getComponent(lastPage).setVisible(true);
            backHandler.mouseClicked(e);
        }
    });
    btnBack_5.setBounds(12, 525, 97, 25);
    RegisterPage.add(btnBack_5);

    JButton btnExit_6 = new JButton("Exit");
    btnExit_6.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            parent.setVisible(false);
            parent.dispose();
        }
    });
    btnExit_6.setBounds(909, 525, 97, 25);
    RegisterPage.add(btnExit_6);

    JLabel lblAddress = new JLabel("Address*");
    lblAddress.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblAddress.setBounds(141, 217, 56, 16);
    RegisterPage.add(lblAddress);

    address = new JTextField();
    address.setBounds(241, 215, 142, 22);
    RegisterPage.add(address);
    address.setColumns(10);

    address2 = new JTextField();
    address2.setBounds(241, 260, 142, 22);
    RegisterPage.add(address2);
    address2.setColumns(10);

    JLabel lblCity = new JLabel("City*");
    lblCity.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblCity.setBounds(141, 308, 56, 16);
    RegisterPage.add(lblCity);

    city = new JTextField();
    city.setBounds(241, 306, 142, 22);
    RegisterPage.add(city);
    city.setColumns(10);

    JLabel lblAddress_1 = new JLabel("Address 2");
    lblAddress_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblAddress_1.setBounds(141, 263, 77, 16);
    RegisterPage.add(lblAddress_1);

    JLabel lblZip = new JLabel("Zip*");
    lblZip.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblZip.setBounds(141, 402, 56, 16);
    RegisterPage.add(lblZip);

    zip = new JTextField();
    zip.setBounds(241, 400, 142, 22);
    RegisterPage.add(zip);
    zip.setColumns(10);

    JLabel lblState = new JLabel("State*");
    lblState.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblState.setBounds(141, 355, 56, 16);
    RegisterPage.add(lblState);

    state = new JTextField();
    state.setBounds(241, 353, 142, 22);
    RegisterPage.add(state);
    state.setColumns(10);

    JLabel lblRequired = new JLabel("* = required");
    lblRequired.setBounds(301, 39, 88, 16);
    RegisterPage.add(lblRequired);

    JLabel lblLicenseInfo = new JLabel("License Information");
    lblLicenseInfo.setFont(new Font("Tahoma", Font.PLAIN, 16));
    lblLicenseInfo.setBounds(459, 257, 148, 27);
    RegisterPage.add(lblLicenseInfo);

    JLabel lblNumber = new JLabel("Number*");
    lblNumber.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblNumber.setBounds(506, 310, 71, 16);
    RegisterPage.add(lblNumber);

    license = new JTextField();
    license.setBounds(642, 306, 116, 22);
    RegisterPage.add(license);
    license.setColumns(10);

    JLabel lblDateOfBirth = new JLabel("Date of Birth*");
    lblDateOfBirth.setBounds(506, 372, 88, 16);
    RegisterPage.add(lblDateOfBirth);

    birthMonth = new JComboBox();
    birthMonth.setModel(new DefaultComboBoxModel(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
            "Aug", "Sep", "Oct", "Nov", "Dec" }));
    birthMonth.setBounds(642, 370, 71, 22);
    RegisterPage.add(birthMonth);

    birthDay = new JComboBox();
    birthDay.setModel(new DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
            "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
            "27", "28", "29", "30", "31" }));
    birthDay.setBounds(708, 370, 62, 22);
    RegisterPage.add(birthDay);

    List<Integer> years = new ArrayList<Integer>();
    for (int i = 1915; i <= 2015; ++i) {
        years.add(i);
    }

    birthYear = new JComboBox(years.toArray());
    birthYear.setBounds(769, 370, 97, 22);
    RegisterPage.add(birthYear);

    JButton btnContinue = new JButton("Continue ->");
    btnContinue.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            register(parent);

        }
    });
    btnContinue.setBounds(674, 428, 133, 34);
    RegisterPage.add(btnContinue);

    JLabel lblConfirmPassword = new JLabel("Confirm Password*");
    lblConfirmPassword.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblConfirmPassword.setBounds(506, 174, 121, 16);
    RegisterPage.add(lblConfirmPassword);

    repassword = new JPasswordField();
    repassword.setBounds(642, 172, 116, 22);
    RegisterPage.add(repassword);

    JLabel lblNewLabel_3 = new JLabel("Credit card #*");
    lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblNewLabel_3.setBounds(141, 448, 93, 16);
    RegisterPage.add(lblNewLabel_3);

    cardNumber = new JTextField();
    cardNumber.setBounds(241, 443, 142, 28);
    RegisterPage.add(cardNumber);
    cardNumber.setColumns(10);

    JLabel lblCardExp = new JLabel("Card exp*");
    lblCardExp.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblCardExp.setBounds(141, 496, 82, 16);
    RegisterPage.add(lblCardExp);

    cardExpMonth = new JComboBox();
    cardExpMonth.setModel(new DefaultComboBoxModel(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }));
    cardExpMonth.setBounds(238, 493, 77, 27);
    RegisterPage.add(cardExpMonth);

    cardExpDay = new JComboBox();
    cardExpDay.setModel(new DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25",
            "26", "27", "28", "29", "30", "31" }));
    cardExpDay.setBounds(312, 493, 71, 27);
    RegisterPage.add(cardExpDay);

    JLabel lblLicenseState = new JLabel("License state*");
    lblLicenseState.setFont(new Font("Tahoma", Font.PLAIN, 14));
    lblLicenseState.setBounds(506, 338, 88, 16);
    RegisterPage.add(lblLicenseState);

    licenseState = new JTextField();
    licenseState.setBounds(642, 333, 116, 28);
    RegisterPage.add(licenseState);
    licenseState.setColumns(10);

    RegisterPage.setVisible(false);
}

From source file:com.cch.aj.entryrecorder.frame.EntryJFrame.java

private int FillProductComboBox(JComboBox comboBox, int id, int mouldId) {
    int result = -1;
    comboBox.removeAll();/* w  w  w . jav a2  s.c o  m*/
    List<Product> allProducts = this.productService.GetAllEntities();
    if (allProducts.size() > 0) {
        List<Product> products = allProducts.stream()
                .filter(x -> x.getMouldId() != null && x.getMouldId().getId() == mouldId)
                .collect(Collectors.toList());
        if (products.size() > 0) {
            List<ComboBoxItem<Product>> productNames = products.stream().sorted(comparing(x -> x.getCode()))
                    .map(x -> ComboBoxItemConvertor.ConvertToComboBoxItem(x, x.getCode(), x.getId()))
                    .collect(Collectors.toList());
            Product product = new Product();
            product.setId(0);
            product.setCode("- Select -");
            productNames.add(0, new ComboBoxItem<Product>(product, product.getCode(), product.getId()));
            ComboBoxItem[] productNamesArray = productNames.toArray(new ComboBoxItem[productNames.size()]);
            comboBox.setModel(new DefaultComboBoxModel(productNamesArray));
            if (id != 0) {
                ComboBoxItem<Product> currentProductName = productNames.stream().filter(x -> x.getId() == id)
                        .findFirst().get();
                result = productNames.indexOf(currentProductName);
            } else {
                result = 0;
            }
            comboBox.setSelectedIndex(result);
        }
    }
    return result;
}

From source file:jeplus.JEPlusFrameMain.java

/** 
 * Creates new form EPlusFrame /* ww  w. ja v a2s.c  o m*/
 */
public JEPlusFrameMain() {

    initComponents();

    this.setTitle(getVersionInfo());

    // tabTexts.setTabComponentAt(0, new ButtonTabComponent (tabTexts));
    jplParameterTree = new JPanel_ParameterTree(Project);
    jplTree.add(this.jplParameterTree, BorderLayout.CENTER);
    initProjectSection();
    initBatchOptions();

    EPlusExecAgents.add(new EPlusAgentLocal(Project.getExecSettings()));
    TrnsysExecAgents.add(new TrnsysAgentLocal(Project.getExecSettings()));
    InselExecAgents.add(new InselAgentLocal(Project.getExecSettings()));
    String[] options = { ExecAgents.get(0).getAgentID() };
    this.cboExecutionType.setModel(new DefaultComboBoxModel(options));
    this.cboExecutionTypeActionPerformed(null);

    this.cboSampleOpt.setModel(new DefaultComboBoxModel(EPlusBatch.SampleType.values()));

    OutputPanel = new EPlusTextPanelOld("Output", EPlusTextPanel.VIEWER_MODE);
    // Start a new thread for output panel
    new Thread(OutputPanel).start();
    OutputPanel.appendContent("Welcome to jEPlus!\n");
    TpnEditors.add(OutputPanel);
    TpnEditors.setSelectedComponent(OutputPanel);

    jplProgConfPanel = new JPanelProgConfiguration(null, JEPlusConfig.getDefaultInstance());
    jplIDFConvPanel = new JPanel_IDFVersionUpdater(this, JEPlusConfig.getDefaultInstance(), this.getProject());
    jplPythonPanel = new JPanelRunPython(this, JEPlusConfig.getDefaultInstance(),
            getProject() == null ? "./" : getProject().resolveWorkDir());
    jplReadVarsPanel = new JPanel_RunReadVars(this);
    //        TpnUtilities.add("Configure Programs", jplProgConfPanel);
    TpnUtilities.add("Run Python", jplPythonPanel);
    TpnUtilities.add("IDF Converter", jplIDFConvPanel);
    TpnUtilities.add("Run ReadVars", jplReadVarsPanel);

    // put the frame in the centre of screen
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int frameWidth = 1000;
    int frameHeight = 740;
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    setSize(frameWidth, frameHeight);
    setLocation((screenWidth - frameWidth) / 2, (screenHeight - frameHeight) / 2);
}