Example usage for javax.swing DefaultListModel addElement

List of usage examples for javax.swing DefaultListModel addElement

Introduction

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

Prototype

public void addElement(E element) 

Source Link

Document

Adds the specified component to the end of this list.

Usage

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

private void dbFieldListMousePreformd(MouseEvent evt) {
    if (JMouseEventUtil.buttonLeftClick(1, evt)) {
        KeyValue kv = (KeyValue) dbFieldList.getSelectedValue();
        if (kv != null) {
            dbFieldText.setText(kv.key);
            dbValue.setText(kv.value);/*from  w  w w.  j  a va 2  s  . c o  m*/
            pkCheckBox.setSelected(kv.pk);
        }
    }
    if (JMouseEventUtil.buttonRightClick(1, evt)) {
        JPopupMenuUtil.newInstance(dbFieldList).addJMenuItem("/?", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                List<KeyValue> list = new ArrayList<KeyValue>();
                DefaultListModel model = (DefaultListModel) dbFieldList.getModel();
                for (int ii = 0; ii < model.getSize(); ii++) {
                    KeyValue kv = (KeyValue) model.get(ii);
                    list.add(kv);
                }
                Collections.sort(list, new Comparator<KeyValue>() {
                    @Override
                    public int compare(KeyValue o1, KeyValue o2) {
                        return o1.key.compareTo(o2.key);
                    }
                });
                DefaultListModel model1 = new DefaultListModel();
                for (KeyValue kv : list) {
                    model1.addElement(kv);
                }
                dbFieldList.setModel(model1);
            }
        }).addJMenuItem("/?PK", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Object[] values = dbFieldList.getSelectedValues();
                if (values != null) {
                    for (Object v : values) {
                        KeyValue kv = (KeyValue) v;
                        kv.pk = !kv.pk;
                    }
                }
            }
        }).applyEvent(evt).show();
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java

private void updateTagList() {
    DefaultListModel m = new DefaultListModel();
    m.addElement(NoTag.getSingleton());
    for (ManageableType t : TagManager.getSingleton().getAllElements()) {
        Tag ta = (Tag) t;/*from  ww  w  .j ava  2  s .c  om*/
        m.addElement(ta);
    }
    jXGroupsList.setModel(m);
}

From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java

private void populate_barbers() {
    List<Staff> allStaff = staffCrudService.findAll();
    if (allStaff != null) {
        DefaultListModel<String> model = new DefaultListModel<>();

        for (int i = 0; i < staffCrudService.count(); i++) {
            model.addElement(allStaff.get(i).getName());
        }//from   w ww.java 2  s. c  om
        jList2.setModel(model);
    }
}

From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java

private void populate_styles() {
    List<Style> allStyles = styleCrudService.findAll();
    if (allStyles != null) {
        DefaultListModel<String> model = new DefaultListModel<>();

        for (int i = 0; i < styleCrudService.count(); i++) {
            model.addElement(allStyles.get(i).getStyle_name());
        }/* w  w  w .j a v  a  2s.  c om*/
        jList3.setModel(model);
    }
}

From source file:de.tor.tribes.ui.components.GroupSelectionList.java

private void resetModel() {
    HashMap<Tag, ListItem.RELATION_TYPE> storedState = new HashMap<>();
    for (int i = 0; i < getModel().getSize(); i++) {
        ListItem item = getItemAt(i);//from  ww  w.  j a  v a 2  s  . c om
        storedState.put(item.getTag(), item.getState());
    }
    DefaultListModel model = new DefaultListModel();

    for (Tag tag : TagUtils.getTags(Tag.CASE_INSENSITIVE_ORDER)) {
        ListItem item = new ListItem(tag);
        if (storedState.get(tag) != null) {
            item.setState(storedState.get(tag));
        }
        model.addElement(item);
    }
    setModel(model);
    checkStateAndRepaint();
}

From source file:Demo.ScatterGraph.java

public ScatterGraph(int sampleNb, List<String> paraType_list) {
    this.sampleNb = sampleNb;
    this.paraType_list = paraType_list;

    // widgets: charts(JFreeChart), parameter selectors (JList)
    DefaultListModel xModel = new DefaultListModel();
    xSelector = new JList(xModel);
    JScrollPane xSelPane = new JScrollPane();
    xSelPane.setViewportView(xSelector);

    DefaultListModel yModel = new DefaultListModel();
    ySelector = new JList(yModel);
    JScrollPane ySelPane = new JScrollPane();
    ySelPane.setViewportView(ySelector);

    charts = new JFreeChart[paraType_list.size()][paraType_list.size()];
    for (int i = 0; i < paraType_list.size(); i++) {
        String para = paraType_list.get(i);
        xModel.addElement(para);
        yModel.addElement(para);//from   w  w  w . j  a  va2s.c om

        for (int j = 0; j < paraType_list.size(); j++) {
            charts[i][j] = null;
        }
    }

    charts[0][0] = CreateChart(0, 0);
    chartPane = new ChartPanel(charts[0][0]);

    xSelector.setSelectedIndex(0);
    ySelector.setSelectedIndex(0);

    xSelector.addMouseListener(this);
    ySelector.addMouseListener(this);

    // layout
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.BOTH;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 20;
    gbc.weighty = 12;
    gbc.gridheight = 4;
    add(chartPane, gbc);

    gbc.insets = new Insets(5, 5, 5, 20);
    gbc.gridx = 1;
    gbc.weightx = 1;
    gbc.gridheight = 1;

    gbc.gridy = 0;
    gbc.weighty = 1;
    add(new JLabel("X :"), gbc);
    gbc.gridy = 2;
    add(new JLabel("Y :"), gbc);

    gbc.gridy = 1;
    gbc.weighty = 5;
    add(xSelPane, gbc);
    gbc.gridy = 3;
    add(ySelPane, gbc);
}

From source file:imageuploader.ImgWindow.java

private void jCB_ColorsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCB_ColorsActionPerformed
    // TODO add your handling code here:
    eventCounter++;/*from w  w w .j a  v a 2s .c  o m*/

    if (evt.getActionCommand().equals("comboBoxChanged")) {

        if (jCB_Colors.getModel().getSize() > 0) {
            String a = jCB_Colors.getSelectedItem().toString();
            DefaultListModel listM = (DefaultListModel) jL_Info.getModel();

            if (eventCounter > 2) {

                if (listM.contains(a) == false) {
                    listM.addElement(a);
                    // boolean add = list.add(jCB_Colors.getSelectedItem().toString());
                }
            }

        }

    }

}

From source file:de.tor.tribes.ui.windows.ReportRulesDialog.java

public final void rebuildRuleList() {
    DefaultListModel model = new DefaultListModel();

    for (ReportRule entry : ReportManager.getSingleton().getRules()) {
        model.addElement(entry);
    }// w  w w . j av a  2  s  .  c om

    jRuleList.setModel(model);
}

From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java

private void pickListRemoveAllAction(final JList availableList, final JList selectedList) {
    final DefaultListModel availableListModel = (DefaultListModel) availableList.getModel();
    final DefaultListModel selectedListModel = (DefaultListModel) selectedList.getModel();
    int size = selectedList.getModel().getSize();
    for (int i = 0; i < size; i++) {
        availableListModel.addElement(selectedListModel.getElementAt(i));
    }/*from  w w w.  jav a2  s.  com*/
    selectedListModel.clear();
}

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

private void putToDbFieldList(Map<String, String> pkMap, Map<String, String> columnMap) {
    DefaultListModel dbFieldListModel = new DefaultListModel();
    for (String key : columnMap.keySet()) {
        KeyValue k = new KeyValue();
        k.key = key;/*from www .  jav  a  2  s  . c o  m*/
        k.value = columnMap.get(key);
        dbFieldListModel.addElement(k);
    }
    for (String key : pkMap.keySet()) {
        KeyValue k = new KeyValue();
        k.key = key;
        k.value = pkMap.get(key);
        k.pk = true;
        dbFieldListModel.addElement(k);
    }
    dbFieldList.setModel(dbFieldListModel);
}