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:org.shaman.rpg.editor.dialog.DialogVisualElement.java

private void addButtonEvent(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonEvent
    @SuppressWarnings("unchecked")
    DefaultListModel<String> listModel = (DefaultListModel<String>) personsList.getModel();
    listModel.addElement("NoName");
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

public final void initIndicatorProjectManager() {
    File f = new File(
            org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator" + File.separator + "project.xml");
    this.alertIndicatorProjectManager = org.yccheok.jstock.gui.Utils.fromXML(IndicatorProjectManager.class, f);
    if (this.alertIndicatorProjectManager != null) {
        log.info("alertIndicatorProjectManager loaded from " + f.toString() + " successfully.");
    } else {/*from w ww.  ja va 2  s. c o m*/
        this.alertIndicatorProjectManager = new IndicatorProjectManager(
                org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator",
                OperatorIndicator.Type.AlertIndicator);
    }

    // Cleanup unused files.
    Set<String> validFileNames = new HashSet<String>();
    for (int i = 0, size = this.alertIndicatorProjectManager.getNumOfProject(); i < size; i++) {
        String PROJECTNAME = this.alertIndicatorProjectManager.getProject(i).toUpperCase();
        validFileNames.add(PROJECTNAME + ".XML");
        validFileNames.add(PROJECTNAME + "-JHOTDRAW.XML");
    }
    validFileNames.add("PROJECT.XML");

    File[] files = new File(org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator" + File.separator)
            .listFiles();
    for (File file : files) {
        if (validFileNames.contains(file.getName().toUpperCase())) {
            continue;
        }
        file.delete();
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            final DefaultListModel defaultListModel = (DefaultListModel) IndicatorPanel.this.jList1.getModel();
            defaultListModel.clear();
            for (int i = 0; i < IndicatorPanel.this.alertIndicatorProjectManager.getNumOfProject(); i++) {
                defaultListModel.addElement(IndicatorPanel.this.alertIndicatorProjectManager.getProject(i));
            }
            if (IndicatorPanel.this.jList1.getModel().getSize() > 0) {
                // Select first element.
                IndicatorPanel.this.jList1.setSelectedIndex(0);
            }
        }
    });
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

public final void initModuleProjectManager() {
    final File f = new File(
            org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "module" + File.separator + "project.xml");
    this.moduleIndicatorProjectManager = org.yccheok.jstock.gui.Utils.fromXML(IndicatorProjectManager.class, f);
    if (this.moduleIndicatorProjectManager != null) {
        log.info("moduleIndicatorProjectManager loaded from " + f.toString() + " successfully.");
    } else {//from   ww  w . j  a  va2 s  .co m
        this.moduleIndicatorProjectManager = new IndicatorProjectManager(
                org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "module",
                OperatorIndicator.Type.ModuleIndicator);
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            final DefaultListModel defaultListModel = (DefaultListModel) jList2.getModel();
            defaultListModel.clear();
            for (int i = 0; i < IndicatorPanel.this.moduleIndicatorProjectManager.getNumOfProject(); i++) {
                defaultListModel.addElement(IndicatorPanel.this.moduleIndicatorProjectManager.getProject(i));
            }
        }
    });
}

From source file:paquete.HollywoodUI.java

private void cb_list_modificaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cb_list_modificaItemStateChanged
    this.tf_nombre_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getNombre());
    this.tf_edad_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getEdad() + "");
    this.tf_nacionalidad_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getNacionalidad());
    //aplicando todos las peliculas a la lista
    DefaultListModel<Pelicula> lista_peliculas_actor = new DefaultListModel<>();
    for (int i = 0; i < ((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().size(); i++) {
        lista_peliculas_actor.addElement(((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().get(i));
        System.out.println(i + 1 + ")" + ((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().get(i));
    }// w w w  .  j a  v  a 2s .  c  o m
    this.list_peliculas_modificar.setModel(lista_peliculas_actor);
}

From source file:pro.miner.classess.MergeListFreqCounter.java

public static void countFreq() {
    Form_domain_expert.pbofwordnet.setIndeterminate(true);

    list1_list2_freq_model.removeAllElements();
    Form_domain_expert.list1_list2_freq.removeAll();

    mergeListFreq.clear();/*  w ww.  ja  v a 2 s  .  com*/
    mergeListProb.clear();

    DefaultListModel list1_list2_model = new DefaultListModel();

    for (int i = 0; i < Form_domain_expert.list1_list2.getModel().getSize(); i++) {
        String word = Form_domain_expert.list1_list2.getModel().getElementAt(i).toString();
        fillProbAndFreq(word);

        Double Frequency = Double.parseDouble(mergeListFreq.get(word).toString());

        if (Frequency > 1.0) {
            list1_list2_model.addElement(Form_domain_expert.list1_list2.getModel().getElementAt(i));
            list1_list2_freq_model.addElement(Double.parseDouble(mergeListFreq.get(word).toString()));
        }
    }

    Form_domain_expert.pbofwordnet.setIndeterminate(false);
    Form_domain_expert.list1_list2_freq.setModel(list1_list2_freq_model);
    Form_domain_expert.list1_list2.setModel(list1_list2_model);
}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void initUI() {
    setLayout(new GridBagLayout());

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    components = new ArrayList<JComponent>();
    checks = new ArrayList<JCheckBox>();

    int size = paramList.size();
    boolean shouldExpand = false;
    boolean needScroll = false;
    for (int i = 0; i < size; i++) {
        final int pos = i;
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            components.add(null);//from   ww  w  .j a  v a2s .c om
            checks.add(null);
            initHiddenParameterValues(param);
            continue;
        }
        String source = param.getSource();
        String defaultSource = param.getDefaultSource();

        if ((defaultSource != null) && !defaultSource.trim().equals("")) {
            try {
                param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param));
            } catch (NextSqlException e) {
                Show.error(e);
            }
        }

        final JComponent component;
        int anchor = GridBagConstraints.WEST;
        double y = 0.0;
        int expand = GridBagConstraints.HORIZONTAL;
        if ((source != null) && !source.equals("")) {
            List<IdName> values = new ArrayList<IdName>();
            try {
                if (param.isManualSource()) {
                    if (!param.isDependent()) {
                        values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy());
                    }
                } else {
                    int index = source.indexOf(".");
                    int index2 = source.lastIndexOf(".");
                    String tableName = source.substring(0, index);
                    String columnName;
                    String shownColumnName = null;
                    if (index == index2) {
                        columnName = source.substring(index + 1);
                    } else {
                        columnName = source.substring(index + 1, index2);
                        shownColumnName = source.substring(index2 + 1);
                    }
                    values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName,
                            columnName, shownColumnName, param.getOrderBy());
                }
            } catch (NextSqlException e) {
                error = true;
                Show.error(e);
            } catch (InvalidSqlException e) {
                String m = I18NSupport.getString("source.dialog.valid");
                Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
            }
            if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) {
                component = new JComboBox();
                final JComboBox combo = (JComboBox) component;
                combo.setRenderer(new IdNameRenderer());
                combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
                for (int j = 0, len = values.size(); j < len; j++) {
                    combo.addItem(values.get(j));
                }

                combo.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            IdName in = null;
                            if (combo.getSelectedIndex() > 0) {
                                in = (IdName) combo.getSelectedItem();
                            }
                            parameterSelection(pos, in);
                        }
                    }
                });
                AutoCompleteDecorator.decorate(combo);
                needScroll = false;
            } else {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;

                DefaultListModel model = new DefaultListModel();
                for (int j = 0, len = values.size(); j < len; j++) {
                    model.addElement(values.get(j));
                }
                List srcList = Arrays.asList(model.toArray());
                component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    // needed for saved parameters on rerun
                    protected void onSetRight() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getDestinationElements().toArray();
                            if (values.length == 0) {
                                values = new Object[] { ParameterUtil.NULL };
                            }
                            parameterSelection(pos, values);
                        }
                    }
                };
                ((ListSelectionPanel) component).setListSize(scrListDim);
                ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(),
                        new IdNameComparator(param.getOrderBy()));

                shouldExpand = true;
            }

        } else {
            if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;
                ;
                component = new ListAddPanel(param) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getElements().toArray();
                            parameterSelection(pos, values);
                        }
                    }
                };
            } else {
                needScroll = false;
                if (param.getValueClassName().equals("java.util.Date")) {
                    component = new JXDatePicker();
                    ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent e) {
                            if ("date".equals(e.getPropertyName())) {
                                parameterSelection(pos, ((JXDatePicker) component).getDate());
                            }
                        }
                    });
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) component.getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.sql.Timestamp")
                        || param.getValueClassName().equals("java.sql.Time")) {
                    component = new JDateTimePicker() {
                        protected void onChange() {
                            parameterSelection(pos, getDate());
                        }
                    };
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker())
                            .getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.lang.Boolean")) {
                    component = new JCheckBox();
                    ((JCheckBox) component).addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
                            boolean selected = abstractButton.getModel().isSelected();
                            parameterSelection(pos, selected);
                        }
                    });
                } else {
                    component = new JTextField(25);
                    ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() {

                        @Override
                        public void changedUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void insertUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void removeUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        private void updateFromTextField(DocumentEvent e) {
                            java.awt.EventQueue.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Object value = null;
                                    try {
                                        if ("".equals(((JTextField) component).getText().trim())) {
                                            value = null;
                                        } else {
                                            value = ParameterUtil.getParameterValueFromString(
                                                    param.getValueClassName(),
                                                    ((JTextField) component).getText());
                                        }
                                        parameterSelection(pos, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        LOG.error(e.getMessage(), e);
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
        components.add(component);
        final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore"));
        checks.add(cb);

        final JLabel label = new JLabel(getRuntimeParameterName(param));
        panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5), 0, 0));
        final JComponent addComponent;
        if (needScroll) {
            JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scr.setPreferredSize(listDim);
            addComponent = scr;
        } else {
            addComponent = component;
        }
        panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand,
                new Insets(5, 0, 5, 5), 0, 0));
        int checkAnchor = GridBagConstraints.WEST;
        if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) {
            checkAnchor = GridBagConstraints.NORTHWEST;
        }

        if (Globals.getParametersIgnore()) {
            panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE,
                    new Insets(5, 0, 5, 5), 0, 0));
        }

        cb.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (cb.isSelected()) {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(false);
                    }
                    label.setEnabled(false);
                    addComponent.setEnabled(false);
                    param.setIgnore(true);
                } else {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(true);
                    }
                    label.setEnabled(true);
                    addComponent.setEnabled(true);
                    param.setIgnore(false);
                }
            }
        });
    }

    // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter)
    // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here
    for (int i = 0; i < size; i++) {
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            populateDependentParameters(param, false);
        }
    }

    if (!shouldExpand) {
        panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }

    JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrPanel.setPreferredSize(scrDim);
    scrPanel.setMinimumSize(scrDim);

    add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
    setParameterValues(parametersValues);
    setParameterIgnore(parametersIgnore);
}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

@SuppressWarnings("unchecked")
private void initParameterValue(JComponent component, Object value, String paramName,
        List<Serializable> defaultValues) {
    if (value == null) {
        return;//from  ww w. j  a va2s . c om
    }
    if (component instanceof JTextField) {
        ((JTextField) component).setText(value.toString());
    } else if (component instanceof JComboBox) {
        JComboBox combo = ((JComboBox) component);
        List<IdName> values = (List<IdName>) value;
        combo.removeAllItems();
        combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
        for (int j = 0, len = values.size(); j < len; j++) {
            combo.addItem(values.get(j));
        }
        Object old = parametersValues.get(paramName);
        if (old != null) {
            combo.setSelectedItem(old);
        } else if ((defaultValues != null) && (defaultValues.size() > 0)) {
            Serializable id = defaultValues.get(0);
            if (id instanceof IdName) {
                id = ((IdName) id).getId();
            }
            combo.setSelectedItem(findIdName(combo.getModel(), id));
        }
    } else if (component instanceof ListSelectionPanel) {
        ListSelectionPanel lsp = (ListSelectionPanel) component;
        DefaultListModel model = new DefaultListModel();
        if (value != null) {
            List<IdName> values = (List<IdName>) value;
            for (int j = 0, len = values.size(); j < len; j++) {
                model.addElement(values.get(j));
            }
        }
        ArrayList srcList = new ArrayList(Arrays.asList(model.toArray()));

        Object old = parametersValues.get(paramName);
        Object[] selected = new Object[0];
        if (old != null) {
            selected = (Object[]) old;
        } else if ((defaultValues != null) && (defaultValues.size() > 0)) {
            selected = new Object[defaultValues.size()];
            for (int k = 0, len = selected.length; k < len; k++) {
                Serializable id = defaultValues.get(k);
                if (id instanceof IdName) {
                    id = ((IdName) id).getId();
                }
                IdName in = findIdName(srcList, id);
                selected[k] = in;
            }
        }
        List dstList = Arrays.asList(selected);

        if (!srcList.containsAll(dstList)) {
            dstList = new ArrayList();
            parametersValues.put(paramName, null);
        } else {
            srcList.removeAll(dstList);
        }
        if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) {
            dstList = new ArrayList();
        }
        lsp.setLists(srcList, dstList);

    } else if (component instanceof ListAddPanel) {
        ListAddPanel lap = (ListAddPanel) component;
        DefaultListModel model = new DefaultListModel();
        if (value != null) {
            List<Object> values = (List<Object>) value;
            for (int j = 0, len = values.size(); j < len; j++) {
                model.addElement(values.get(j));
            }
        }
        ArrayList srcList = new ArrayList(Arrays.asList(model.toArray()));

        Object old = parametersValues.get(paramName);
        Object[] selected = new Object[0];
        if (old != null) {
            selected = (Object[]) old;
        } else if ((defaultValues != null) && (defaultValues.size() > 0)) {
            selected = new Object[defaultValues.size()];
            for (int k = 0, len = selected.length; k < len; k++) {
                Serializable id = defaultValues.get(k);
                if (id instanceof IdName) {
                    id = ((IdName) id).getId();
                }
                selected[k] = id;
            }
        }
        List dstList = Arrays.asList(selected);
        if (!srcList.containsAll(dstList)) {
            dstList = new ArrayList();
            parametersValues.put(paramName, null);
        } else {
            srcList.removeAll(dstList);
        }
        if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) {
            dstList = new ArrayList();
        }

        lap.setElements(dstList);
    } else if (component instanceof JDateTimePicker) {
        ((JDateTimePicker) component).setDate((Date) value);
    } else if (component instanceof JXDatePicker) {
        ((JXDatePicker) component).setDate((Date) value);
    } else if (component instanceof JCheckBox) {
        ((JCheckBox) component).setSelected((Boolean) value);
    }
}

From source file:rss.RSSController.java

public void parseElement(java.util.Vector<channel> tabChannels, javax.swing.DefaultListModel names) {
    if (_inputs.size() > 0) {
        String input = _inputs.get(0);
        JSONParser parser = new JSONParser();
        String jsonText = input;/*from www. ja v a2  s.c  o  m*/
        try {
            JSONArray array = (JSONArray) parser.parse(jsonText);
            tabChannels.removeAllElements();
            for (int i = 0; i < array.size(); ++i) {
                channel c = new channel();
                JSONObject obj = (JSONObject) array.get(i);
                Object[] tab = obj.values().toArray();
                System.out.println(tab);
                JSONArray arr = (JSONArray) obj.get("items");
                c.setName((String) obj.get("title"));
                for (int j = 0; j < arr.size(); ++j) {
                    JSONObject o = (JSONObject) arr.get(j);
                    c.push((String) o.get("description"));
                }
                tabChannels.addElement(c);
                names.addElement((String) tab[3]);
                //                 return (c);

            }
        } catch (ParseException pe) {
        }

    } else {
    }
}

From source file:sd_conexion_bd.Servicios.java

/**
  * Cargar la lista de los contactos del usuario de la base de datos y mostararla como lista en el tab contactos
  * lista es la lista donde se va a presentar los contactos del usuario
*//*w w w. j av  a  2 s .com*/
public void cargar_contactos(JList lista, String userName, int u_id) {
    try {
        this.conectar("localhost:3306", "mensajeria", "mensajeria", "1234");
        ////this.conectar("192.168.43.21:3306", "mensajeria","mensajeria","1234");
        this.consulta = this.conexion
                .prepareStatement("call consultar_contactos(\"" + userName + "\",\"" + u_id + "\");");
        this.datos = this.consulta.executeQuery();
        DefaultListModel modelo = new DefaultListModel();
        while (this.datos.next()) {
            modelo.addElement(datos.getString("nombre") + " " + datos.getString("apellido"));
        }
        lista.setModel(modelo);
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Servicios.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, "No se pudo conectar correctamente a la base de datos");
    }
}

From source file:sd_conexion_bd.Servicios.java

/**
  * Cargar la lista de los contactos del usuario de la base de datos y mostararla como lista en el tab contactos
  * lista es la lista donde se va a presentar los contactos del usuario
*//* w  ww .ja  v a 2s .  c  o m*/
public void cargar_nuevoscontactos(JList nuevosContactos, String userName, int u_id) {
    try {
        //System.out.println(userName +u_id);
        this.conectar("localhost:3306", "mensajeria", "mensajeria", "1234");
        ////this.conectar("192.168.43.21:3306", "mensajeria","mensajeria","1234");
        this.consulta = this.conexion
                .prepareStatement("call buscar_nuevos_contactos(\"" + userName + "\",\"" + u_id + "\");");
        this.datos = this.consulta.executeQuery();
        DefaultListModel modelo = new DefaultListModel();
        while (this.datos.next()) {
            //System.out.println(datos.getString("nombre")+"\n");
            modelo.addElement(datos.getString("nombre") + " " + datos.getString("apellido"));
        }
        //System.out.println(modelo);
        nuevosContactos.setModel(modelo);
        //System.out.println(nuevosContactos);
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Servicios.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, "No se pudo conectar correctamente a la base de datos");
    }
}