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:op.care.info.DlgDiag.java

private void btnAddHospitalActionPerformed(ActionEvent e) {
    final PnlEditHospital pnlHospital = new PnlEditHospital(new Hospital());
    JidePopup popup = GUITools.createPanelPopup(pnlHospital, new Closure() {
        @Override/*  w w  w . j a va2  s. c  om*/
        public void execute(Object o) {
            if (o != null) {
                Hospital hospital = EntityTools.merge((Hospital) o);
                cmbKH.setModel(new DefaultComboBoxModel(new Hospital[] { hospital }));
            }
        }
    }, btnAddHospital);
    GUITools.showPopup(popup, SwingConstants.EAST);
}

From source file:op.care.info.DlgDiag.java

private void fillCMBs() {
    EntityManager em = OPDE.createEM();//from   ww w.j a  v  a2s  . c o  m
    Query queryArzt = em.createQuery("SELECT a FROM GP a WHERE a.status >= 0 ORDER BY a.name, a.vorname");
    java.util.List<GP> listAerzte = queryArzt.getResultList();
    listAerzte.add(0, null);

    Query queryKH = em.createQuery("SELECT k FROM Hospital k WHERE k.state >= 0 ORDER BY k.name");
    java.util.List<Hospital> listKH = queryKH.getResultList();
    listKH.add(0, null);
    em.close();

    cmbArzt.setModel(new DefaultComboBoxModel(listAerzte.toArray()));
    cmbArzt.setRenderer(GPTools.getRenderer());
    cmbArzt.setSelectedIndex(0);

    cmbKH.setModel(new DefaultComboBoxModel(listKH.toArray()));
    cmbKH.setRenderer(HospitalTools.getKHRenderer());
    cmbKH.setSelectedIndex(0);

    cmbSicherheit.setModel(new DefaultComboBoxModel(new String[] { SYSTools.xx("misc.msg.diag.security.na"),
            SYSTools.xx("misc.msg.diag.security.confirmed"), SYSTools.xx("misc.msg.diag.security.suspected"),
            SYSTools.xx("misc.msg.diag.security.rulingout"),
            SYSTools.xx("misc.msg.diag.security.conditionafter") }));
    cmbSicherheit.setSelectedIndex(1);

    cmbKoerper.setModel(new DefaultComboBoxModel(
            new String[] { SYSTools.xx("misc.msg.diag.side.na"), SYSTools.xx("misc.msg.diag.side.left"),
                    SYSTools.xx("misc.msg.diag.side.right"), SYSTools.xx("misc.msg.diag.side.both") }));
}

From source file:op.care.info.DlgDiag.java

/**
 * This method is called from within the constructor to
 * initialize the form.// ww w .java2s . c  o m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    txtSuche = new JXSearchField();
    lblTX = new JLabel();
    jspDiagnosen = new JScrollPane();
    lstDiag = new JList();
    lblDiagBy = new JLabel();
    cmbArzt = new JComboBox<>();
    btnAddGP = new JButton();
    cmbKH = new JComboBox<>();
    btnAddHospital = new JButton();
    lblSecurity = new JLabel();
    lblSide = new JLabel();
    cmbKoerper = new JComboBox<>();
    cmbSicherheit = new JComboBox<>();
    jScrollPane1 = new JScrollPane();
    txtBemerkung = new JTextArea();
    lblInterval = new JLabel();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnOK = new JButton();

    //======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== jPanel1 ========
    {
        jPanel1.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED));
        jPanel1.setLayout(new FormLayout(
                "default, $lcgap, pref, $lcgap, default:grow, $ugap, pref, $lcgap, default:grow, 2*($lcgap, default)",
                "default, $lgap, fill:default, $lgap, fill:104dlu:grow, $lgap, fill:default, $lgap, default, $lgap, fill:default, $lgap, fill:89dlu:grow, $ugap, default, $lgap, default"));

        //---- txtSuche ----
        txtSuche.setFont(new Font("Arial", Font.PLAIN, 14));
        txtSuche.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                txtSucheActionPerformed(e);
            }
        });
        jPanel1.add(txtSuche, CC.xywh(3, 3, 7, 1));

        //---- lblTX ----
        lblTX.setText(null);
        lblTX.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/ambulance2.png")));
        jPanel1.add(lblTX, CC.xy(11, 3));

        //======== jspDiagnosen ========
        {

            //---- lstDiag ----
            lstDiag.setFont(new Font("Arial", Font.PLAIN, 14));
            jspDiagnosen.setViewportView(lstDiag);
        }
        jPanel1.add(jspDiagnosen, CC.xywh(3, 5, 9, 1));

        //---- lblDiagBy ----
        lblDiagBy.setText("Festgestellt durch:");
        lblDiagBy.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblDiagBy, CC.xy(3, 7, CC.RIGHT, CC.DEFAULT));

        //---- cmbArzt ----
        cmbArzt.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbArzt.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbArzt, CC.xywh(5, 7, 5, 1));

        //---- btnAddGP ----
        btnAddGP.setText(null);
        btnAddGP.setBorder(null);
        btnAddGP.setContentAreaFilled(false);
        btnAddGP.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
        btnAddGP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnAddGP.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
        btnAddGP.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnAddGPActionPerformed(e);
            }
        });
        jPanel1.add(btnAddGP, CC.xy(11, 7));

        //---- cmbKH ----
        cmbKH.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbKH.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbKH, CC.xywh(5, 9, 5, 1));

        //---- btnAddHospital ----
        btnAddHospital.setText(null);
        btnAddHospital.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
        btnAddHospital.setBorder(null);
        btnAddHospital.setContentAreaFilled(false);
        btnAddHospital.setBorderPainted(false);
        btnAddHospital.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnAddHospital.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
        btnAddHospital.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnAddHospitalActionPerformed(e);
            }
        });
        jPanel1.add(btnAddHospital, CC.xy(11, 9));

        //---- lblSecurity ----
        lblSecurity.setText("Diagnosesicherheit:");
        lblSecurity.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblSecurity, CC.xy(7, 11));

        //---- lblSide ----
        lblSide.setText("K\u00f6rperseite:");
        lblSide.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblSide, CC.xy(3, 11, CC.RIGHT, CC.DEFAULT));

        //---- cmbKoerper ----
        cmbKoerper.setModel(new DefaultComboBoxModel<>(
                new String[] { "Nicht festgelegt", "links", "rechts", "beidseitig" }));
        cmbKoerper.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbKoerper, CC.xy(5, 11));

        //---- cmbSicherheit ----
        cmbSicherheit.setModel(new DefaultComboBoxModel<>(new String[] { "Nicht festgelegt", "gesichert",
                "Verdacht auf", "Ausschlu\u00df von", "Zustand nach" }));
        cmbSicherheit.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbSicherheit, CC.xywh(9, 11, 3, 1));

        //======== jScrollPane1 ========
        {

            //---- txtBemerkung ----
            txtBemerkung.setColumns(20);
            txtBemerkung.setRows(5);
            txtBemerkung.setFont(new Font("Arial", Font.PLAIN, 14));
            jScrollPane1.setViewportView(txtBemerkung);
        }
        jPanel1.add(jScrollPane1, CC.xywh(3, 13, 9, 1));

        //---- lblInterval ----
        lblInterval.setText("text");
        jPanel1.add(lblInterval, CC.xywh(3, 15, 5, 1));

        //======== panel1 ========
        {
            panel1.setLayout(new HorizontalLayout(5));

            //---- btnCancel ----
            btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
            btnCancel.setText(null);
            btnCancel.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCancelActionPerformed(e);
                }
            });
            panel1.add(btnCancel);

            //---- btnOK ----
            btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
            btnOK.setText(null);
            btnOK.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnOKActionPerformed(e);
                }
            });
            panel1.add(btnOK);
        }
        jPanel1.add(panel1, CC.xywh(7, 15, 5, 1, CC.RIGHT, CC.DEFAULT));
    }
    contentPane.add(jPanel1, BorderLayout.CENTER);
    setSize(730, 565);
    setLocationRelativeTo(getOwner());
}

From source file:op.care.med.inventory.DlgCloseStock.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from  w  w  w .  j av a  2 s .c o m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    jScrollPane1 = new JScrollPane();
    txtInfo = new JTextPane();
    rbLeer = new JRadioButton();
    rbStellen = new JRadioButton();
    txtLetzte = new JTextField();
    lblEinheiten = new JLabel();
    rbAbgelaufen = new JRadioButton();
    jSeparator1 = new JSeparator();
    jLabel2 = new JLabel();
    jLabel3 = new JLabel();
    rbGefallen = new JRadioButton();
    cmbBestID = new JComboBox();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnOk = new JButton();

    //======== this ========
    setResizable(false);
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    //======== jPanel1 ========
    {
        jPanel1.setBorder(null);
        jPanel1.setLayout(new FormLayout("14dlu, $lcgap, 145dlu, $lcgap, 41dlu, $lcgap, 93dlu, $lcgap, 14dlu",
                "14dlu, $lgap, fill:70dlu:grow, 4*($lgap, fill:default), $lgap, $rgap, $lgap, fill:default, $lgap, $rgap, $lgap, default, $lgap, 14dlu"));

        //======== jScrollPane1 ========
        {

            //---- txtInfo ----
            txtInfo.setEditable(false);
            txtInfo.setFont(new Font("Arial", Font.PLAIN, 14));
            jScrollPane1.setViewportView(txtInfo);
        }
        jPanel1.add(jScrollPane1, CC.xywh(3, 3, 5, 1));

        //---- rbLeer ----
        rbLeer.setSelected(true);
        rbLeer.setText("Die Packung ist nun leer");
        rbLeer.setFont(new Font("Arial", Font.PLAIN, 14));
        rbLeer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbLeerActionPerformed(e);
            }
        });
        jPanel1.add(rbLeer, CC.xy(3, 5));

        //---- rbStellen ----
        rbStellen.setText("Beim Vorab Stellen haben Sie die letzten ");
        rbStellen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbStellen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbStellenActionPerformed(e);
            }
        });
        jPanel1.add(rbStellen, CC.xywh(3, 7, 2, 1));

        //---- txtLetzte ----
        txtLetzte.setText("jTextField1");
        txtLetzte.setFont(new Font("Arial", Font.PLAIN, 14));
        txtLetzte.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                txtLetzteFocusLost(e);
            }
        });
        jPanel1.add(txtLetzte, CC.xy(5, 7));

        //---- lblEinheiten ----
        lblEinheiten.setText("Einheiten verbraucht.");
        lblEinheiten.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(lblEinheiten, CC.xy(7, 7));

        //---- rbAbgelaufen ----
        rbAbgelaufen.setText(
                "Die Packung ist abgelaufen oder wird nicht mehr ben\u00f6tigt. Bereit zur Entsorgung.");
        rbAbgelaufen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbAbgelaufen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbAbgelaufenActionPerformed(e);
            }
        });
        jPanel1.add(rbAbgelaufen, CC.xywh(3, 9, 5, 1));
        jPanel1.add(jSeparator1, CC.xywh(3, 13, 5, 1));

        //---- jLabel2 ----
        jLabel2.setText("Als n\u00e4chstes Packung soll die Nummer");
        jLabel2.setFont(new Font("Arial", Font.PLAIN, 14));
        jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
        jPanel1.add(jLabel2, CC.xy(3, 15));

        //---- jLabel3 ----
        jLabel3.setText("angebrochen werden.");
        jLabel3.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(jLabel3, CC.xy(7, 15));

        //---- rbGefallen ----
        rbGefallen.setText(
                "<html>Die Packung ist <font color=\"red\">runter gefallen</font> oder <font color=\"red\">verschwunden</font> und muss ausgebucht werden.</html>");
        rbGefallen.setFont(new Font("Arial", Font.PLAIN, 14));
        rbGefallen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbGefallenActionPerformed(e);
            }
        });
        jPanel1.add(rbGefallen, CC.xywh(3, 11, 5, 1));

        //---- cmbBestID ----
        cmbBestID.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbBestID.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbBestID.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                cmbBestIDItemStateChanged(e);
            }
        });
        jPanel1.add(cmbBestID, CC.xy(5, 15));

        //======== panel1 ========
        {
            panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

            //---- btnClose ----
            btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
            btnClose.setText(null);
            btnClose.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCloseActionPerformed(e);
                }
            });
            panel1.add(btnClose);

            //---- btnOk ----
            btnOk.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
            btnOk.setText(null);
            btnOk.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnOkActionPerformed(e);
                }
            });
            panel1.add(btnOk);
        }
        jPanel1.add(panel1, CC.xy(7, 19, CC.RIGHT, CC.DEFAULT));
    }
    contentPane.add(jPanel1);
    pack();
    setLocationRelativeTo(getOwner());

    //---- buttonGroup1 ----
    ButtonGroup buttonGroup1 = new ButtonGroup();
    buttonGroup1.add(rbLeer);
    buttonGroup1.add(rbStellen);
    buttonGroup1.add(rbAbgelaufen);
    buttonGroup1.add(rbGefallen);
}