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:techtonic.Onview.java

public static void setjcbX_Axis(Vector<String> s) {
    Onview.jcbX_Axis.setModel(new DefaultComboBoxModel(s));
}

From source file:techtonic.Techtonic.java

public static void setjcbX_Axis(Vector<String> s) {
    Techtonic.jcbX_Axis.setModel(new DefaultComboBoxModel(s));
}

From source file:DatabaseBrowser.java

protected void populateSchemaBox() {
    try {/* w w  w  . ja v a 2s .  c  o  m*/
        DatabaseMetaData dmd = connection.getMetaData();
        ResultSet rset = dmd.getSchemas();
        Vector values = new Vector();
        while (rset.next()) {
            values.addElement(rset.getString(1));
        }
        rset.close();
        schemaBox.setModel(new DefaultComboBoxModel(values));
        schemaBox.setEnabled(values.size() > 0);
    } catch (Exception e) {
        schemaBox.setEnabled(false);
    }
}

From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelConnection.java

private void initComponents() {
    labelDescription = new JLabel("<html><body><p>"
            + Localization.getString("platform.plugin.setupwizard.connection.intro") + "</p></body></html>");

    // Firmware options
    firmwareCombo = new JComboBox<>();
    firmwareCombo.addActionListener(a -> setFirmware());
    labelFirmware = new JLabel("Firmware:");

    // Baud rate options
    baudCombo = new JComboBox<>();
    baudCombo.setModel(new DefaultComboBoxModel<>(
            new String[] { "2400", "4800", "9600", "19200", "38400", "57600", "115200", "230400" }));
    baudCombo.setSelectedIndex(6);//from  ww  w.  jav  a2s  .  c  o m
    baudCombo.setToolTipText("Select baudrate to use for the serial port.");
    baudCombo.addActionListener(e -> this.setBaudRate());
    labelBaud = new JLabel(Localization.getString("platform.plugin.setupwizard.port-rate"));

    portCombo = new JComboBox<>();
    portCombo.addActionListener(e -> this.setPort());
    labelPort = new JLabel(Localization.getString("platform.plugin.setupwizard.port"));

    connectButton = new JButton(Localization.getString("platform.plugin.setupwizard.connect"));
    connectButton.addActionListener((e) -> {
        try {
            getBackend().connect(getBackend().getSettings().getFirmwareVersion(),
                    getBackend().getSettings().getPort(),
                    Integer.valueOf(getBackend().getSettings().getPortRate()));
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    });

    labelVersion = new JLabel(Localization.getString("platform.plugin.setupwizard.unknown-version"));
    labelVersion.setVisible(false);

    labelNotSupported = new JLabel(
            Localization.getString("platform.plugin.setupwizard.connection.not-supported"));
    labelNotSupported.setIcon(ImageUtilities.loadImageIcon("icons/information24.png", false));
    labelNotSupported.setVisible(false);
}

From source file:View.DialogoEstadisticas.java

private void llenarCmbPeriodos() {
    h = new Historico();
    h.buscaPeriodos();/*from   w  ww. ja v  a  2 s .  c  om*/

    /*String[] periodos = new String[h.getNumeroPeriodos()];
    int i = 0;
    for (String p : h.getPeriodos()) {
    periodos[i] = formatPeriodo(p);
    i++;
    }
    cmbPeriodoF.setModel(new DefaultComboBoxModel((Object[]) periodos));
    cmbPeriodoF.setSelectedIndex(h.getNumeroPeriodos() - 1);
    cmbPeriodoI.setModel(new DefaultComboBoxModel((Object[]) periodos));
    cmbPeriodoF.setSelectedIndex(h.getNumeroPeriodos() - 1);
     */
    String[] periodos = h.getPeriodos();
    cmbPeriodoI.setModel(new DefaultComboBoxModel((Object[]) periodos));
    cmbPeriodoI.setSelectedIndex(0);
    cmbPeriodoF.setModel(new DefaultComboBoxModel((Object[]) periodos));
    cmbPeriodoF.setSelectedIndex(h.getNumeroPeriodos() - 1);
    fechaIntervaloI = periodos[0];
    fechaIntervaloF = periodos[h.getNumeroPeriodos() - 1];
}

From source file:techtonic.Onview.java

public static void setjcbY_Axis(Vector<String> s) {
    Onview.jcbY_Axis.setModel(new DefaultComboBoxModel(s));
}

From source file:techtonic.Techtonic.java

public static void setjcbY_Axis(Vector<String> s) {
    Techtonic.jcbY_Axis.setModel(new DefaultComboBoxModel(s));
}

From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java

public DiscoveryManagerDialogV2(JFrame frame, File projectDir) {
    this.frame = frame;
    this.projectDir = projectDir;
    setTitle("Discovery Manager");
    setBounds(100, 100, 960, 364);/*from w  w w  . j ava2  s .com*/
    getContentPane().setLayout(new BorderLayout());
    {

        JPanel buttonPane = new JPanel();
        getContentPane().add(buttonPane, BorderLayout.NORTH);
        {
            buttonPane.setLayout(new BorderLayout(0, 0));
            {
                JPanel panel = new JPanel();
                buttonPane.add(panel);
                panel.setLayout(null);
                {
                    depthComboBox = new JComboBox();
                    depthComboBox.setModel(
                            new DefaultComboBoxModel(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }));
                    depthComboBox.setBounds(46, 11, 70, 20);
                    panel.add(depthComboBox);
                }

                JLabel lblMode = new JLabel("Depth:");
                lblMode.setBounds(6, 14, 46, 14);
                panel.add(lblMode);

                JLabel lblAddress = new JLabel("Address:");
                lblAddress.setBounds(172, 14, 56, 14);
                panel.add(lblAddress);

                addressTextField = new JTextField();
                addressTextField.setBounds(230, 11, 113, 20);
                panel.add(addressTextField);
                addressTextField.setColumns(10);

                JLabel lblLabel = new JLabel("Label:");
                lblLabel.setBounds(360, 14, 56, 14);
                panel.add(lblLabel);

                labelTextField = new JTextField();
                labelTextField.setBounds(400, 11, 113, 20);
                panel.add(labelTextField);
                labelTextField.setColumns(10);

                autoLabelCheckBox = new JCheckBox("auto-label");
                autoLabelCheckBox.setBounds(520, 11, 113, 20);
                autoLabelCheckBox.setSelected(true);
                panel.add(autoLabelCheckBox);
                postDiscoveryCheckBox = new JCheckBox("Post Discovery");
                postDiscoveryCheckBox.setBounds(620, 11, 153, 20);
                postDiscoveryCheckBox.setSelected(true);
                panel.add(postDiscoveryCheckBox);

            }
        }
        {
            JPanel panel = new JPanel();
            buttonPane.add(panel, BorderLayout.EAST);
            final JButton stopStartButton = new JButton("Start");
            panel.add(stopStartButton);
            stopStartButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    if ("Start".equals(stopStartButton.getText())) {
                        onStartDiscoveryPre(stopStartButton);
                        onStartDiscovery();
                        onStartDiscoveryPost(stopStartButton);
                    } else {
                        onStopDiscoveryPre(stopStartButton);
                        onStopDiscovery();
                        onStopDiscoveryPost(stopStartButton);

                    }
                }
            });
            stopStartButton.setActionCommand("Start");
            getRootPane().setDefaultButton(stopStartButton);
            {
                pauseResumeButton.setEnabled(false);
                panel.add(pauseResumeButton);
                pauseResumeButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        if ("Pause".equals(pauseResumeButton.getText())) {
                            pauseResumeButton.setEnabled(false);
                            onPauseDiscovery();
                            pauseResumeButton.setText("Resume");
                            pauseResumeButton.setEnabled(true);
                        } else {
                            pauseResumeButton.setEnabled(false);
                            onResumeDiscovery();
                            pauseResumeButton.setText("Pause");
                            pauseResumeButton.setEnabled(true);
                        }
                    }
                });
            }
        }
    }
    {
        lblDiscoveredDevices = new JTextArea();
        JScrollPane scrolltxt = new JScrollPane(lblDiscoveredDevices);
        lblDiscoveredDevices.append("Discovery process output");
        getContentPane().add(scrolltxt, BorderLayout.CENTER);
    }
    {
        JPanel statusPanel = new JPanel();
        getContentPane().add(statusPanel, BorderLayout.SOUTH);
        statusPanel.setLayout(new BorderLayout(0, 0));
        {
            JPanel panel = new JPanel();
            statusPanel.add(panel);
            panel.setLayout(new BorderLayout(0, 0));
            //panel.setSize(100:100);
            {
                loggerConsole = new JTextArea();
                JScrollPane scrolltxt = new JScrollPane(loggerConsole);
                loggerConsole.append("Discovery logger console");
                panel.add(scrolltxt, BorderLayout.CENTER);
            }
        }
    }
    {
        Logger logger = Logger.getRootLogger();
        logger.setLevel(Level.INFO);
        logger.addAppender(new AppenderSkeleton() {
            @Override
            protected void append(final LoggingEvent loggingEvent) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        loggerConsole.append(loggingEvent.getMessage().toString());
                        loggerConsole.append("\n");
                    }
                });
            }

            @Override
            public void close() {
            }

            @Override
            public boolean requiresLayout() {
                return false;
            }
        });
    }
}

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

private void initGUI() {
    try {/*from  ww  w  . ja v a 2 s. co  m*/
        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, 1);
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("java\u6a94");
                }
                {
                    javaSrcFileText = new JTextField();
                    jPanel1.add(javaSrcFileText);
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(javaSrcFileText, false);
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("method\u958b\u59cb");
                }
                {
                    methodStartText = new JTextField();
                    methodStartText.setText("\"#. ${method} .s\"");
                    jPanel1.add(methodStartText);
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("method\u7d50\u675f");
                }
                {
                    methodEndText = new JTextField();
                    methodEndText.setText("\"#. ${method} .e\"");
                    jPanel1.add(methodEndText);
                }
                {
                    jLabel4 = new JLabel();
                    jPanel1.add(jLabel4);
                    jLabel4.setText(
                            "\u7528\u684c\u9762\u8a2d\u5b9a\u6a94\u6c7a\u5b9adebug\u958b\u8d77\u6216\u95dc\u9589");
                }
                {
                    ComboBoxModel onOffDebugSwitchComboBoxModel = new DefaultComboBoxModel(
                            new String[] { "false", "true" });
                    onOffDebugSwitchComboBox = new JComboBox();
                    jPanel1.add(onOffDebugSwitchComboBox);
                    onOffDebugSwitchComboBox.setModel(onOffDebugSwitchComboBoxModel);
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u57f7\u884c");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(587, 404);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

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

public void updateDropDown() {
    String[] items = new String[panels.keySet().size()];
    int i = 0;/*from w  w w . ja  v a 2 s.c om*/
    for (String s : panels.keySet()) {
        items[i] = s;
        i++;
    }

    Object selectedItem = variableReferenceDropDown.getSelectedItem();

    variableReferenceDropDown.setModel(new DefaultComboBoxModel(items));

    if (selectedItem != null) {
        variableReferenceDropDown.setSelectedItem(selectedItem);
    }
}