Example usage for javax.swing DefaultComboBoxModel addElement

List of usage examples for javax.swing DefaultComboBoxModel addElement

Introduction

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

Prototype

public void addElement(E anObject) 

Source Link

Usage

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private static DefaultComboBoxModel getSuggestedModel(java.util.List<String> list, String text) {
    DefaultComboBoxModel m = new DefaultComboBoxModel();
    for (String s : list) {
        // if(s.startsWith(text))
        m.addElement(s);
    }/*  ww w.j a v a2 s.c o  m*/
    return m;
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private static DefaultComboBoxModel getCustNameSuggestedModel(java.util.List<String> list, String text) {
    DefaultComboBoxModel m = new DefaultComboBoxModel();
    for (String s : list) {

        // if(s.startsWith(text))
        String nameLength = cusName.getText();
        if (nameLength.length() > 2) {
            m.addElement(s);
        }/*www.  j a v  a 2  s.  c o m*/
    }
    return m;
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private static DefaultComboBoxModel getItemSuggestedModel(java.util.List<String> list, String text) {
    DefaultComboBoxModel m = new DefaultComboBoxModel();
    for (String s : list) {
        String itemLength = null;

        itemLength = itemName.getText();
        // if(s.startsWith(text))
        if (itemLength.length() > 2) {
            //if(s.startsWith(text))
            m.addElement(s);
        }/*from  www  . jav  a  2 s. co  m*/
    }
    return m;

}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private static DefaultComboBoxModel getContactNoSuggestedModel(java.util.List<String> list, String text) {
    DefaultComboBoxModel m = new DefaultComboBoxModel();
    for (String s : list) {
        String phoneLength = null;

        phoneLength = cusPhoneNo.getText();
        //    if(s.startsWith(text))
        if (phoneLength.length() > 5) {
            if (s.startsWith(text)) {
                m.addElement(s);
            }//ww w . j a  v  a  2 s.c  om
        }
    }
    return m;

}

From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.ApplicationProperties.java

private void setupForm(final String settingsPath) {
    this.setTitle("System Properties");
    try {/* www .j  a v  a2  s . c o  m*/
        theFormControl = new FormControl(this, settingsPath);
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    // Set fonts
    isSystemChange = true;
    final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final Font[] fonts = env.getAllFonts();
    DefaultListModel model = new DefaultListModel();
    for (int i = 0; i < fonts.length; i++) {
        final Font font = fonts[i];
        model.add(i, font.getName());
    }
    lstFont.setModel(model);

    // Set styles
    model = new DefaultListModel();
    model.addElement("Plain");
    model.addElement("Bold");
    model.addElement("Italic");
    model.addElement("Bold Italic");
    lstStyle.setModel(model);

    // Set sizes
    model = new DefaultListModel();
    model.addElement("8");
    model.addElement("10");
    model.addElement("12");
    model.addElement("14");
    model.addElement("18");
    model.addElement("20");
    model.addElement("22");
    model.addElement("24");
    lstSize.setModel(model);
    txtFontSize.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(final DocumentEvent e) {
            updateFontSize();
        }

        public void removeUpdate(final DocumentEvent e) {
            updateFontSize();
        }

        public void insertUpdate(final DocumentEvent e) {
            updateFontSize();
        }
    });

    model = new DefaultListModel();
    for (String favourite : personalSettings.getFavourites()) {
        model.addElement(favourite);
    }
    lstFavourites.setModel(model);

    model = new DefaultListModel();
    for (PersonalSettings.FileDescriptions descriptions : personalSettings.getFilesToIgnore()) {
        model.addElement(descriptions);
    }
    lstFilesToIgnore.setModel(model);

    final DefaultComboBoxModel cmbModel = new DefaultComboBoxModel();
    for (PersonalSettings.TextPosition position : PersonalSettings.TextPosition.values()) {
        cmbModel.addElement(position);
    }
    cmbTextPosition.setModel(cmbModel);

    chkSortRunning.setSelected(personalSettings.isSortRunningAscending());
    chkSortPending.setSelected(personalSettings.isSortPendingAscending());
    chkSortFailed.setSelected(personalSettings.isSortFailedAscending());
    chkSortDeposited.setSelected(personalSettings.isSortDepositedAscending());
    chkSortComplete.setSelected(personalSettings.isSortCompleteAscending());
    txtNoOfRetries.setText(String.format("%d", personalSettings.getNoOfRetries()));

    isSystemChange = false;
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

public void addUserGroupHandlers(JLabel lblCleanupDirectory, JLabel lblDelay, JTextField txtCleanupDelay,
        JComboBox cmbCleanupType, JList lstCharacterTranslations, JComboBox cmbCharacterPosition,
        JTextField txtTranslateFrom, JTextField txtTranslateTo, JComboBox cmbUserGroupDesc) {
    theLblCleanupDirectory = lblCleanupDirectory;
    theLblDelay = lblDelay;/* w  w  w. j av  a  2  s .  c  o  m*/
    theTxtCleanupDelay = txtCleanupDelay;
    theCmbCleanupType = cmbCleanupType;
    theLstCharacterTranslations = lstCharacterTranslations;
    theCmbCharacterPosition = cmbCharacterPosition;
    theTxtTranslateFrom = txtTranslateFrom;
    theTxtTranslateTo = txtTranslateTo;
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (UserGroupData.ECleanupType cleanupType : UserGroupData.ECleanupType.values()) {
        model.addElement(cleanupType);
    }
    theCmbCleanupType.setModel(model);
    theCmbCleanupType.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cmbCleanupTypeActionPerformed(evt);
        }
    });
    theCmbUserGroupDesc = cmbUserGroupDesc;
    model = new DefaultComboBoxModel();
    for (UserGroupData.UserGroupDesc userGroupDesc : UserGroupData.UserGroupDesc.values()) {
        model.addElement(userGroupDesc);
    }
    theCmbUserGroupDesc.setModel(model);
    theCmbCharacterPosition = cmbCharacterPosition;
    model = new DefaultComboBoxModel();
    for (UserGroupData.ECharacterPosition charPosition : UserGroupData.ECharacterPosition.values()) {
        model.addElement(charPosition);
    }
    theCmbCharacterPosition.setModel(model);
    DefaultListModel translationModel = new DefaultListModel();
    theLstCharacterTranslations.setModel(translationModel);
    loadTranslations();
    theLstCharacterTranslations.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            characterTranslationValueChanged(evt);
        }
    });
    theTxtTranslateFrom.addCaretListener(new javax.swing.event.CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent evt) {
            userGroupCaretUpdate(evt);
        }
    });
    theTxtTranslateTo.addCaretListener(new javax.swing.event.CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent evt) {
            userGroupCaretUpdate(evt);
        }
    });
    checkCleanupItems();
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

public void addMetaDataHandlers(JList dataList, JComboBox dataTypeCombo, JPanel dataLookupFrame,
        JList dataTypeListItems, JList cmsMappingsList, JComboBox cmsFieldCombo, JList dnxTypeList,
        JList dnxDetailList, JList dcTypeList, JList dcXsiList, JList dcTermsTypeList, JTabbedPane dnxDcPane) {
    theDataList = dataList;/*from ww w  .j a  v  a2s.c  o m*/
    theDataList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dataListValueChanged(evt);
        }
    });
    theCmbDataType = dataTypeCombo;
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (EDataType dataType : EDataType.values()) {
        model.addElement(dataType);
    }
    theCmbDataType.setModel(model);
    theCmbDataType.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            cmbDataTypeActionPerformed(evt);
        }
    });
    theDataLookupFrame = dataLookupFrame;
    theDataLookupList = dataTypeListItems;
    DefaultListModel listModel = new DefaultListModel();
    theDataLookupList.setModel(listModel);
    theDataLookupList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dataLookupListValueChanged(evt);
        }
    });
    theCmsMappingsList = cmsMappingsList;
    listModel = new DefaultListModel();
    theCmsMappingsList.setModel(listModel);
    theCmsMappingsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            cmsMappingListValueChanged(evt);
        }
    });
    theDnxTypeList = dnxTypeList;
    theDnxTypeList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dnxTypeListValueChanged(evt);
        }
    });
    theCmsFieldCombo = cmsFieldCombo;
    tehDnxDetailList = dnxDetailList;
    tehDnxDetailList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dnxDetailListValueChanged(evt);
        }
    });
    theDcTypeList = dcTypeList;
    theDcTypeList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dcTypeListValueChanged(evt);
        }
    });
    theDcXsiList = dcXsiList;
    theDcXsiList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dcXsiListValueChanged(evt);
        }
    });
    theDcTermsTypeList = dcTermsTypeList;
    theDcTermsTypeList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            dcTermsTypeListValueChanged(evt);
        }
    });
    theDnxDcPane = dnxDcPane;
    theDnxDcPane.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            tabDnxDcStateChanged(evt);
        }
    });
    try {
        loadDNXValues();
    } catch (Exception ex) {
        configuratorFrame.showError("Error loading DNX values", ex.getMessage());
    }
    loadDCValues();
    loadDCXsiValues();
    loadDCTermsValues();
    loadCMSFields();
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

private void loadCMSFields() {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("Id");
    model.addElement("Title");
    model.addElement("Publisher");
    model.addElement("Author");
    model.addElement("Reference");
    model.addElement("Deposit Type");
    model.addElement("Description");
    model.addElement("Coverage");
    model.addElement("Rights");
    model.addElement("Relation");
    theCmsFieldCombo.setModel(model);/*w w w. j  av  a  2s. co  m*/
}

From source file:op.care.supervisor.PnlHandover.java

private List<Component> addFilters() {
    List<Component> list = new ArrayList<Component>();

    Pair<DateTime, DateTime> minmax = NReportTools.getMinMax();
    if (minmax != null) {
        final DefaultComboBoxModel yearModel = new DefaultComboBoxModel();
        for (int year = new LocalDate().getYear(); year >= minmax.getFirst().getYear(); year--) {
            yearModel.addElement(year);
        }//from  ww  w  .ja v  a 2s .c om

        JPanel innerPanel = new JPanel();
        innerPanel.setOpaque(false);
        innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.PAGE_AXIS));
        txtSearch = new JXSearchField(SYSTools.xx("misc.msg.searchphrase"));
        txtSearch.setInstantSearchDelay(100000);
        txtSearch.setFont(SYSConst.ARIAL14);
        txtSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (SYSTools.catchNull(txtSearch.getText()).trim().length() > 3) {
                    SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML(
                            NReportTools.getNReports4Handover((Homes) cmbHomes.getSelectedItem(),
                                    txtSearch.getText().trim(),
                                    Integer.parseInt(yearModel.getSelectedItem().toString())),
                            txtSearch.getText().trim(),
                            Integer.parseInt(yearModel.getSelectedItem().toString())), false);
                }
            }
        });
        innerPanel.add(txtSearch);
        JButton btnSearchGeneralReports = GUITools
                .createHyperlinkButton("nursingrecords.handover.searchHandovers", null, null);
        btnSearchGeneralReports.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List listHandovers = HandoversTools.getBy(
                        Integer.parseInt(yearModel.getSelectedItem().toString()),
                        (Homes) cmbHomes.getSelectedItem());
                SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML(listHandovers, "",
                        Integer.parseInt(yearModel.getSelectedItem().toString())), false);
            }
        });
        innerPanel.add(btnSearchGeneralReports);
        yearCombo = new JXComboBox(yearModel);
        yearCombo.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                txtSearch.postActionEvent();
            }
        });

        JPanel myPanel = new JPanel();
        myPanel.setOpaque(false);
        myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.LINE_AXIS));
        myPanel.add(innerPanel);
        myPanel.add(yearCombo);
        list.add(myPanel);
    }

    cmbHomes = new JComboBox();
    cmbHomes.setFont(SYSConst.ARIAL14);
    HomesTools.setComboBox(cmbHomes);
    cmbHomes.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() != ItemEvent.SELECTED)
                return;
            reloadDisplay();
        }
    });
    list.add(cmbHomes);

    tbResidentFirst = GUITools.getNiceToggleButton("nursingrecords.handover.residentFirst");
    SYSPropsTools.restoreState("nursingrecords.handover.tbResidentFirst", tbResidentFirst);
    tbResidentFirst.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            SYSPropsTools.storeState("nursingrecords.handover.tbResidentFirst", tbResidentFirst);
            reload();
        }
    });
    tbResidentFirst.setHorizontalAlignment(SwingConstants.LEFT);
    list.add(tbResidentFirst);

    return list;
}

From source file:op.tools.SYSCalendar.java

public static DefaultComboBoxModel createMonthList(LocalDate start, LocalDate end) {
    DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
    for (LocalDate month = start; month.compareTo(end) <= 0; month = month.plusMonths(1)) {
        dcbm.addElement(month);
    }/*from   w  w  w.j a v a  2  s .c o  m*/
    return dcbm;
}