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:com.litt.core.security.license.gui.CustomerPanel.java

private void initData() {
    initProduct();//from  w  w  w. jav a2 s.  c  om
    comboBoxLicenseType
            .setModel(new DefaultComboBoxModel(new String[] { "DEMO - ", "TRIAL - ",
                    "STANDARD - ", "ENTERPRISE - ?", "DEVELOPMENT - ?" }));
}

From source file:qmod.generator.MainWindow.java

@SuppressWarnings("unchecked")
public MainWindow() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("Quick Mod Generator");

    JLabel lblAuthors = new JLabel("Authors:");

    authorField1 = new JTextField();
    authorField1.setColumns(25);//w  ww  . ja  va2 s  .com

    JButton btnGenerateFile = new JButton("Generate File");
    btnGenerateFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            writeFiles();
        }
    });

    authCombo1.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo1.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo1.setSelectedIndex(0);

    authCombo2.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo2.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo2.setSelectedIndex(0);

    authorField2 = new JTextField();
    authorField2.setColumns(25);

    authCombo3.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo3.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo3.setSelectedIndex(0);

    authorField3 = new JTextField();
    authorField3.setColumns(25);

    JLabel lblCategories = new JLabel("Categories:");

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

    JLabel lblDescription = new JLabel("Description:");

    JEditorPane descriptionField = new JEditorPane();

    JLabel lblLicense = new JLabel("License:");

    licenseField = new JTextField();
    licenseField.setColumns(10);
    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                            .createSequentialGroup()
                            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                                    .createParallelGroup(Alignment.TRAILING).addComponent(btnGenerateFile)
                                    .addGroup(groupLayout.createSequentialGroup().addComponent(lblAuthors)
                                            .addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout
                                                    .createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                                                            .createSequentialGroup()
                                                            .addComponent(
                                                                    authCombo2, GroupLayout.PREFERRED_SIZE, 81,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addGap(6).addComponent(authorField2,
                                                                    GroupLayout.PREFERRED_SIZE, 192,
                                                                    GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(groupLayout.createSequentialGroup().addComponent(
                                                            authCombo1, GroupLayout.PREFERRED_SIZE, 81,
                                                            GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                                                    ComponentPlacement.RELATED)
                                                            .addComponent(
                                                                    authorField1, GroupLayout.DEFAULT_SIZE, 264,
                                                                    Short.MAX_VALUE))
                                                    .addGroup(groupLayout.createSequentialGroup()
                                                            .addComponent(authCombo3,
                                                                    GroupLayout.PREFERRED_SIZE, 81,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addGap(6).addGroup(groupLayout.createParallelGroup(
                                                                    Alignment.LEADING).addComponent(
                                                                            descriptionField)
                                                                    .addGroup(groupLayout
                                                                            .createParallelGroup(
                                                                                    Alignment.LEADING, false)
                                                                            .addComponent(categoriesField)
                                                                            .addComponent(
                                                                                    authorField3,
                                                                                    GroupLayout.DEFAULT_SIZE,
                                                                                    192, Short.MAX_VALUE))
                                                                    .addGroup(groupLayout
                                                                            .createSequentialGroup()
                                                                            .addComponent(licenseField,
                                                                                    GroupLayout.DEFAULT_SIZE,
                                                                                    192, Short.MAX_VALUE)
                                                                            .addPreferredGap(
                                                                                    ComponentPlacement.RELATED)))))))
                                    .addComponent(lblCategories).addComponent(lblDescription))
                            .addGap(84))
                            .addGroup(groupLayout.createSequentialGroup().addComponent(lblLicense)
                                    .addContainerGap(377, Short.MAX_VALUE)))));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
            .createSequentialGroup().addContainerGap()
            .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblAuthors)
                    .addComponent(authorField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(authCombo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(authCombo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField2,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(authCombo3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField3,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblCategories)
                    .addComponent(categoriesField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblDescription)
                    .addComponent(descriptionField, GroupLayout.PREFERRED_SIZE, 100,
                            GroupLayout.PREFERRED_SIZE))
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(groupLayout.createSequentialGroup().addGap(9).addComponent(lblLicense))
                    .addGroup(groupLayout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(licenseField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED, 322, Short.MAX_VALUE).addComponent(btnGenerateFile)
            .addContainerGap()));
    getContentPane().setLayout(groupLayout);

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

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

    JMenuItem mntmNew = new JMenuItem("New");
    mntmNew.setMnemonic(KeyEvent.VK_N);
    mnFile.add(mntmNew);

    JMenuItem mntmOpen = new JMenuItem("Open");
    mnFile.add(mntmOpen);

    JMenuItem mntmSave = new JMenuItem("Save");
    mnFile.add(mntmSave);

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

From source file:br.com.utfpr.pb.view.PedidoVendaView.java

/**
 * Creates new form UsuariosView//from www.  j a  va  2 s.c  om
 */
public PedidoVendaView() {
    try {
        pedido = new Pedido();
        pedido.setTipoPedido(TipoPedido.VENDA);
        pedido.setUsuario(UsuarioController.getInstance().getUsuarioLogado());

        categoriaController = CategoriaController.getInstance();
        produtoController = ProdutoController.getInstance();
        clienteController = ClienteController.getInstance();
        pedidoController = PedidoController.getInstance();
        doubleUtil = DoubleUtil.getInstance();

        initComponents();
        initTable();
        pessoa.setModel(new DefaultComboBoxModel(clienteController.findAll().toArray()));
        modelItens = (DefaultTableModel) jTableItens.getModel();

        Dimension desktopSize = PrincipalView.jDesktopPane.getSize();
        Dimension jInternalFrameSize = getSize();
        setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height) / 2);
        PrincipalView.jDesktopPane.add(this);
        setMaximum(true);
        setVisible(true);
        moveToFront();
        setSelected(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:br.com.utfpr.pb.view.PedidoCompraView.java

/**
 * Creates new form UsuariosView/*from  www.j a  v a2 s  .  c  o m*/
 */
public PedidoCompraView() {
    try {
        pedido = new Pedido();
        pedido.setTipoPedido(TipoPedido.COMPRA);
        pedido.setUsuario(UsuarioController.getInstance().getUsuarioLogado());

        categoriaController = CategoriaController.getInstance();
        produtoController = ProdutoController.getInstance();
        fornecedorController = FornecedorController.getInstance();
        pedidoController = PedidoController.getInstance();
        doubleUtil = DoubleUtil.getInstance();

        initComponents();
        initTable();
        pessoa.setModel(new DefaultComboBoxModel(fornecedorController.findAll().toArray()));
        modelItens = (DefaultTableModel) jTableItens.getModel();

        Dimension desktopSize = PrincipalView.jDesktopPane.getSize();
        Dimension jInternalFrameSize = getSize();
        setLocation((desktopSize.width - jInternalFrameSize.width) / 2,
                (desktopSize.height - jInternalFrameSize.height) / 2);
        PrincipalView.jDesktopPane.add(this);
        setMaximum(true);
        setVisible(true);
        moveToFront();
        setSelected(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.limegroup.gnutella.gui.init.LanguagePanel.java

/**
 * Constructs a LanguagePanel that will notify the given listener when the
 * language changes./*  www .ja  v  a2 s .c  o m*/
 */
public LanguagePanel(ActionListener actionListener) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    this.actionListener = actionListener;
    this.languageLabel = new JLabel();

    languageOptions = new JComboBox<Object>();
    Font font = new Font("Dialog", Font.PLAIN, 11);
    languageOptions.setFont(font);
    Locale[] locales = LanguageUtils.getLocales(font);
    languageOptions.setModel(new DefaultComboBoxModel<Object>(locales));
    languageOptions.setRenderer(LanguageFlagFactory.getListRenderer());

    Locale locale = guessLocale(locales);
    languageOptions.setSelectedItem(locale);

    applySettings(false);

    // It is important that the listener is added after the selected item
    // is set. Otherwise the listener will call methods that are not ready
    // to be called at this point.
    languageOptions.addItemListener(new StateListener());

    add(languageLabel);
    add(Box.createHorizontalStrut(5));
    add(languageOptions);
}

From source file:com.mirth.connect.client.ui.editors.MapperPanel.java

/** Creates new form MapperPanel */
public MapperPanel(MirthEditorPane p) {
    parent = p;//  w ww .j av  a2  s .c om
    initComponents();
    variableTypes = new LinkedHashMap<String, String>();
    variableTypes.put("connector", "Connector Map");
    variableTypes.put("channel", "Channel Map");
    variableTypes.put("globalChannel", "Global Channel Map");
    variableTypes.put("global", "Global Map");
    variableTypes.put("response", "Response Map");

    addTo.setModel(new DefaultComboBoxModel(variableTypes.values().toArray()));

    variableTextField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent arg0) {
        }

        public void insertUpdate(DocumentEvent arg0) {
            if (documentListenerEnabled) {
                updateTable();
                parent.modified = true;
            }
        }

        public void removeUpdate(DocumentEvent arg0) {
            if (documentListenerEnabled) {
                updateTable();
                parent.modified = true;
            }
        }
    });

    mappingTextField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent arg0) {
        }

        public void insertUpdate(DocumentEvent arg0) {
            parent.modified = true;
        }

        public void removeUpdate(DocumentEvent arg0) {
            parent.modified = true;
        }
    });

    defaultValueTextField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent arg0) {
        }

        public void insertUpdate(DocumentEvent arg0) {
            parent.modified = true;
        }

        public void removeUpdate(DocumentEvent arg0) {
            parent.modified = true;
        }
    });

    regularExpressionsScrollPane.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            deselectRows();
        }
    });
    deleteButton.setEnabled(false);
}

From source file:com.mirth.connect.client.ui.ChannelTagDialog.java

@Override
public void setVisible(boolean visible) {
    if (visible) {
        Dimension dlgSize = getPreferredSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            setLocationRelativeTo(null);
        } else {//  w  w  w .  j a v a 2 s. c om
            setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        Set<String> availableTags = new LinkedHashSet<String>(parent.getChannelTagInfo(false).getTags());
        DefaultTableModel model = (DefaultTableModel) tagTable.getModel();
        int rowCount = model.getRowCount();

        for (int i = 0; i < rowCount; i++) {
            availableTags.remove(model.getValueAt(i, 0));
        }

        tagComboBox.setModel(new DefaultComboBoxModel(availableTags.toArray()));

        if (availableTags.size() > 0) {
            tagComboBox.setSelectedIndex(0);
        }

        tagComboBox.requestFocusInWindow();
    }

    super.setVisible(visible);
}

From source file:org.kineticsystem.commons.data.demo.panels.AggregationChartPane.java

/**
 * Constructor.//from   w  ww.  j a v  a  2  s  .  co m
 * @param source This is the source list being modified ate the same time
 *     by many threads.
 */
public AggregationChartPane(ActiveList<RandomContact> source) {

    // Define aggregators.

    GroupAggregator[] aggregators = new GroupAggregator[] { new ContactsPerContinentAggr(),
            new AvgAgePerContinentAggr(), new MaxAgePerContinentAggr(), new MinAgePerContinentAggr() };

    // Aggregator selector.

    DefaultComboBoxModel groupComboModel = new DefaultComboBoxModel(aggregators);
    final JComboBox groupCombo = new JComboBox(groupComboModel);
    groupCombo.setSelectedIndex(1);
    groupCombo.setToolTipText("Select an aggregation function.");

    // Create the dataset.

    dataset = new DefaultCategoryDataset();
    List<Country> countries = RandomContactGenerator.getCountries();
    Set<String> continents = new TreeSet<String>();

    for (Country country : countries) {
        continents.add(country.getContinent());
    }

    for (String continent : continents) {
        dataset.setValue(0, continent, "");
    }

    // Define the aggregated list.

    groups = new GroupMapping<RandomContact>(source);
    groups.setAggregator(aggregators[0]);
    groups.getTarget().addActiveListListener(this);

    // Create the chart.

    JFreeChart chart = ChartFactory.createBarChart("", "Continent", groups.getAggregator().toString(), dataset,
            PlotOrientation.VERTICAL, true, // legend?
            true, // tooltips?
            false // URLs?
    );
    final ValueAxis axis = chart.getCategoryPlot().getRangeAxis();
    axis.setAutoRange(true);
    axis.setRange(0, 250);

    ChartPanel chartPanel = new ChartPanel(chart);

    // Create the selector.

    ActionListener groupComboListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            GroupAggregator aggr = (GroupAggregator) cb.getSelectedItem();
            groups.setAggregator(aggr);
            axis.setLabel(aggr.toString());
        }
    };
    groupCombo.addActionListener(groupComboListener);

    // Layout the GUI.

    Cell cell = new Cell();

    TetrisLayout groupTableLayout = new TetrisLayout(2, 1);
    groupTableLayout.setRowWeight(0, 0);
    groupTableLayout.setRowWeight(1, 100);

    setLayout(groupTableLayout);
    add(groupCombo, cell);
    add(chartPanel, cell);
}

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

public DeriveGroupNodeDialogPane() {
    initComponents();/*from  w w w.  ja v a  2 s  .c  om*/
    // Find out which aggregation functions are loaded.
    Collection<String> list = new ArrayList<>();
    Iterator<FunctionDescription> it = AggregationRegistry.getInstance().getFunctionDescriptions().iterator();
    while (it.hasNext()) {
        FunctionDescription fd = it.next();
        String desc = StringUtils.rightPad(fd.getName(), 20) + fd.getDescription();
        list.add(desc);
    }
    fcomboBox.setModel(new DefaultComboBoxModel<String>(list.toArray(new String[] {})));

}

From source file:gtu.xml.work.CacDBUI4Janna.java

private void initGUI() {
    try {//ww  w  .ja v  a  2s  .c  om
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                GridLayout jPanel1Layout = new GridLayout(10, 2, 5, 5);
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("\u8cc7\u6599\u8868\u540d\u7a31");
                }
                {
                    ComboBoxModel tableNameComboModel = new DefaultComboBoxModel(
                            new String[] { "cac_fcase", "cac_ecase", "cac_fcase_count" });
                    tableNameCombo = new JComboBox();
                    jPanel1.add(tableNameCombo);
                    tableNameCombo.setModel(tableNameComboModel);
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("xml\u6a94\u6848\u4f86\u6e90");
                }
                {
                    srcFileText = new JTextField();
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(srcFileText, false);
                    jPanel1.add(srcFileText);
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("\u7522\u751fsql\u6a94\u540d");
                }
                {
                    destFileNameText = new JTextField();
                    jPanel1.add(destFileNameText);
                }
                {
                    jLabel4 = new JLabel();
                    jPanel1.add(jLabel4);
                    jLabel4.setText("dmv\u6b04\u4f4d\u503c");
                }
                {
                    dmvText = new JTextField();
                    jPanel1.add(dmvText);
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u57f7\u884c");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(541, 361);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}