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.QuartzCronTestUI.java

private void initGUI() {
    try {// w w  w. ja  v a2s.c  om
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("CronExpression", null, jPanel1, null);
                {
                    jPanel2 = new JPanel();
                    jPanel1.add(jPanel2, BorderLayout.NORTH);
                    jPanel2.setPreferredSize(new java.awt.Dimension(439, 34));
                    {
                        cronText = new JTextField();
                        jPanel2.add(cronText);
                        cronText.setText("");
                        cronText.setPreferredSize(new java.awt.Dimension(229, 27));
                    }
                    {
                        executeBtn = new JButton();
                        jPanel2.add(executeBtn);
                        executeBtn.setText("execute");
                        executeBtn.setPreferredSize(new java.awt.Dimension(85, 28));
                        executeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                //XXX
                                try {
                                    CronExpression cexp = new CronExpression(cronText.getText());
                                    Date current = new Date();
                                    setTitle(DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss"));

                                    DefaultListModel cronListModel = new DefaultListModel();
                                    for (int ii = 0, total = Integer
                                            .parseInt(limitText.getText()); ii < total; ii++) {
                                        current = cexp.getNextValidTimeAfter(current);
                                        if (current == null) {
                                            break;
                                        }
                                        cronListModel.addElement(ii + " : "
                                                + DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss"));
                                    }
                                    cronList.setModel(cronListModel);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    JCommonUtil.handleException(e);
                                    return;
                                }
                            }
                        });
                    }
                    {
                        limitText = new JTextField();
                        jPanel2.add(limitText);
                        limitText.setText("2000");
                        limitText.setPreferredSize(new java.awt.Dimension(61, 24));
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(439, 253));
                    {
                        DefaultListModel cronListModel = new DefaultListModel();
                        cronList = new JList();
                        jScrollPane1.setViewportView(cronList);
                        cronList.setModel(cronListModel);
                    }
                }
            }
        }
        pack();
        this.setSize(460, 354);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:com.components.wizard.layout2media.java

private void fill() {
    DefaultListModel m = new DefaultListModel();
    try {//from  w  ww. j  av  a 2s.  c  o m
        String sql = "select * from media";
        pst = connection.prepareStatement(sql);
        rs = pst.executeQuery();
        while (rs.next()) {
            String path = rs.getString("name");
            m.addElement(path);
        }
        jList1.setModel(m);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    } finally {
        try {
            rs.close();
            pst.close();
        } catch (Exception e) {
        }
    }

}

From source file:gui.QTLResultsPanel.java

private void setsimple(Trait trait) {
    if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) {
        DefaultListModel<String> simplemodelModel = new DefaultListModel<String>();
        simplemodelModel.addElement("Model       Adj R^2   SIC");
        for (String l : trait.getBestSimpleModels()) {
            simplemodelModel.addElement(l);
        }/*  w w w  .  j av  a 2 s  . c  om*/
        modelList = new JList<String>(simplemodelModel);
        modelList.addListSelectionListener(this);
        modelList.setFont(new Font("Monospaced", Font.PLAIN, 11));
        modelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        simpleDetails = new JScrollPane(modelList);
        // simple_details.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simpleDetails.setPreferredSize(new Dimension(200, 50));
        simplesplit.setLeftComponent(simpleDetails);
    } else {
        setTrait_simple(trait, simpleright);
    }
}

From source file:gtu.log.finder.ExceptionLogFinderUI.java

private void searchTextBtnAction() {
    File parseFile = getParseFile();
    if (outputLogFile == null || !outputLogFile.exists()) {
        if (parseFile != null) {
            outputLogFile = parseFile;//from   www .  ja v a  2s  . c  o m
        } else {
            JCommonUtil._jOptionPane_showMessageDialog_error("??");
            return;
        }
    }
    String searchTxt = searchText.getText();
    System.out.println("findText ==> " + searchTxt);
    try {
        Pattern startPtn = Pattern.compile("?(\\d+)[]+");
        Pattern searchTextPtn = Pattern.compile(searchTxt, Pattern.CASE_INSENSITIVE);
        if (!ignoreCaseCheckBox.isSelected()) {
            searchTextPtn = Pattern.compile(searchTxt);
        }

        List<ExceptionSection> exceptionSecList = new ArrayList<ExceptionSection>();
        String tempSecStr = null;
        Matcher matcher = null;
        List<String> markLineSectionNumberList = new ArrayList<String>();
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(new FileInputStream(outputLogFile), "utf8"));
        for (String line = null; (line = reader.readLine()) != null;) {
            matcher = startPtn.matcher(line);
            if (matcher.find()) {
                tempSecStr = matcher.group(1);
            }
            if (tempSecStr == null) {
                continue;
            }
            String tmpLine = line.replaceFirst("[\\d]+\\:", "");
            tmpLine = tmpLine.replaceFirst("\\([\\d]+\\)\\:", "");
            if (tmpLine.contains(searchTxt) || searchTextPtn.matcher(tmpLine).find()) {
                System.out.println("\ttempSecStr => " + tempSecStr);
                System.out.println("\ttmpLine => " + tmpLine);
                if (!markLineSectionNumberList.contains(tempSecStr)) {
                    ExceptionSection es = new ExceptionSection();
                    es.line = line;
                    es.sectionNumber = Integer.parseInt(tempSecStr);
                    exceptionSecList.add(es);
                    System.out.println(es);
                    markLineSectionNumberList.add(tempSecStr);
                    tempSecStr = null;
                }
            } else {
                System.out.println(":" + tmpLine);
            }
        }
        reader.close();

        DefaultListModel searchMatchListModel = new DefaultListModel();
        for (int ii = 0; ii < exceptionSecList.size(); ii++) {
            ExceptionSection es = exceptionSecList.get(ii);
            searchMatchListModel.addElement(es);
        }
        searchMatchList.setModel(searchMatchListModel);
        if (exceptionSecList.isEmpty()) {
            JCommonUtil._jOptionPane_showMessageDialog_info("??!");
        }
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.SingleCutOffFilteringController.java

/**
 * Plot the raw KDE for track displacements.
 *
 *//*from w  w  w  .  j a v a2s  .  c  o m*/
public void showMedianDisplInList() {
    DefaultListModel model = (DefaultListModel) singleCutOffPanel.getMedianDisplList().getModel();
    model.clear();
    filteringController.getPlateConditions().stream()
            .map((condition) -> filteringController.getMedianDisplAcrossReplicates(condition))
            .forEach((Double medianDisplForCondition) -> {
                model.addElement(AnalysisUtils.roundThreeDecimals(medianDisplForCondition));
            });
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

ArrayList<ModelIMDbSearchHit> performSearch() {

    DefaultListModel model = new DefaultListModel();
    model.addElement(
            new ModelIMDbSearchHit(Localizer.get("DialogIMDB.list-element.messsage.search-in-progress"))); //$NON-NLS-1$
    listMovies.setModel(model);/*from   w w w. ja v a 2  s.com*/

    ArrayList<ModelIMDbSearchHit> hits = null;

    try {
        hits = IMDbLib.newIMDb(MovieManager.getConfig().getHttpSettings())
                .getSimpleMatches(searchStringField.getText());
        handleSearchResults(hits);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        executeErrorMessage(e);
        dispose();
    }
    return hits;
}

From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java

private void filterProps(String filter) {
    DefaultListModel<ConfigurationMetadataProperty> dlmCfgProps = new DefaultListModel<>();
    for (ConfigurationMetadataProperty item : sortedProps) {
        if (filter == null || item.getId().contains(filter)) {
            if (Utils.isErrorDeprecated(item)) {
                if (bDeprErrorShow) {
                    dlmCfgProps.addElement(item);
                }/*from  ww w.ja v  a  2 s  .co m*/
            } else {
                dlmCfgProps.addElement(item);
            }
        }
    }
    lCfgProps.setModel(dlmCfgProps);
    if (!dlmCfgProps.isEmpty()) {
        lCfgProps.setSelectedIndex(0);
    }
}

From source file:client.InterfaceSalon.java

public void setLobbyList(String liste) {
    DefaultListModel lobbyListContent = new DefaultListModel();

    if (!liste.equals("[]")) {
        try {/*from  w w w  . ja v  a 2s  .  c o m*/
            this.lobbyListJSON = (JSONArray) parser.parse(liste);
        } catch (Exception e) {
            System.out.println("error json : " + e.getLocalizedMessage());
        }

        Iterator it = lobbyListJSON.iterator();

        while (it.hasNext()) {
            JSONObject lobby = (JSONObject) it.next();
            lobbyListContent.addElement(
                    lobby.get("name") + "  " + lobby.get("nbJoueurs") + "/" + lobby.get("nbJoueursMax"));
        }
    }
    lobbyList.setModel(lobbyListContent);
}

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

private void jButton1ActionPerformed(ActionEvent evt) {
    try {//  ww  w .  j a  va 2 s. c om
        DefaultListModel model = JListUtil.createModel();
        String text = ClipboardUtil.getInstance().getContents();
        Validate.notEmpty(text, "");
        StringBuilder pattern = new StringBuilder();
        if (jCheckBox1.isSelected()) {
            pattern.append("\n");
        }
        if (jCheckBox2.isSelected()) {
            pattern.append("\t");
        }
        StringTokenizer tok = new StringTokenizer(text, pattern.toString());
        while (tok.hasMoreElements()) {
            String val = (String) tok.nextElement();
            model.addElement(val);
        }
        jList1.setModel(model);
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

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

private void pickListAddAllAction(final JList sourceList, final JList destinationList) {
    final DefaultListModel availableListModel = (DefaultListModel) sourceList.getModel();
    final DefaultListModel selectedListModel = (DefaultListModel) destinationList.getModel();
    int size = sourceList.getModel().getSize();
    for (int i = 0; i < size; i++) {
        selectedListModel.addElement(availableListModel.getElementAt(i));
    }/* www . j  a  v  a 2 s .c om*/
    availableListModel.clear();
}