Example usage for javax.swing DefaultListModel DefaultListModel

List of usage examples for javax.swing DefaultListModel DefaultListModel

Introduction

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

Prototype

DefaultListModel

Source Link

Usage

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

void handleSearchResults(ArrayList<ModelIMDbSearchHit> hits) {

    final DefaultListModel list = new DefaultListModel();

    boolean noHits = false;

    // Error//ww  w. j  av a  2 s  . com
    if (hits == null) {
        HTTPResult res = imdb.getLastHTTPResult();

        if (res.getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
            list.addElement(new ModelIMDbSearchHit("Connection timed out...")); //$NON-NLS-1$
            noHits = true;
        }
    } else if (hits.size() == 0) {
        list.addElement(
                new ModelIMDbSearchHit(Localizer.get("DialogIMDB.list-element.messsage.no-hits-found"))); //$NON-NLS-1$
        noHits = true;
    } else {
        for (ModelIMDbSearchHit hit : hits)
            list.addElement(hit);
    }

    final boolean setButtonChooseEnabled = !noHits;

    // make changes on EDT
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            setListModel(list);
            listMovies.setSelectedIndex(0);
            getButtonSelect().setEnabled(setButtonChooseEnabled);
        }
    });
}

From source file:de.tor.tribes.ui.algo.AttackTimePanel.java

/**
 * Try to add a new timespan. Before it is checked for intersection
 *
 * @param s The new timespan// ww w. j a v  a  2 s.c o m
 */
protected void addTimeSpan(TimeSpan s) {
    if (s == null) {
        JOptionPaneHelper.showWarningBox(this, "Der angegebene Zeitrahmen ist ungltig", "Warnung");
        return;
    }
    //check if timeframe exists or intersects with other existing frame
    int intersection = -1;

    DefaultListModel model = (DefaultListModel) jTimeFrameList.getModel();
    int entryId = 0;
    for (int i = 0; i < model.getSize(); i++) {
        TimeSpan existingSpan = (TimeSpan) model.getElementAt(i);
        if (!existingSpan.getDirection().equals(TimeSpan.DIRECTION.NONE)) {
            //not for divider!
            if (s.intersects(existingSpan)) {
                intersection = entryId + 1;
                break;
            }
            entryId++;
        }
    }

    if (intersection == -1) {
        //add span
        if (s.getDirection().equals(TimeSpan.DIRECTION.SEND)) {
            ((DefaultListModel) jTimeFrameList.getModel()).add(0, s);
        } else {
            ((DefaultListModel) jTimeFrameList.getModel()).add(jTimeFrameList.getModel().getSize(), s);
        }

        List<TimeSpan> spans = new LinkedList<>();
        for (int i = 0; i < model.getSize(); i++) {
            spans.add((TimeSpan) model.getElementAt(i));
        }

        Collections.sort(spans);
        model = new DefaultListModel();
        for (TimeSpan span : spans) {
            model.addElement(span);
        }
        jTimeFrameList.setModel(model);
    } else {
        JOptionPaneHelper.showWarningBox(this,
                "Das gewhlte Zeitfenster berschneidet sich mit dem " + intersection + ". Eintrag.\n"
                        + "Bitte whle die Zeitfenster so, dass es zu keinen berschneidungen kommt.",
                "Warnung");
        return;
    }
    fireTimeFrameChangedEvent();
}

From source file:cnu.eslab.fileTest.NewJFrame.java

private void initGUI() {
    try {// w w  w .  ja v  a  2 s  .c o  m
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, "North");
            jPanel1.setBounds(12, 434, 590, 66);
            jPanel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mParsingBtn = new JButton();
                jPanel1.add(mParsingBtn);
                mParsingBtn.setText("Parsing");
                mParsingBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalPowerBtn = new JButton();
                jPanel1.add(mTotalPowerBtn);
                mTotalPowerBtn.setText("Phone Total Power");
                mTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mBatteryCapacityBtn = new JButton();
                jPanel1.add(mBatteryCapacityBtn);
                mBatteryCapacityBtn.setText("Battery Capacity");
                mBatteryCapacityBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalCompareBtn = new JButton();
                jPanel1.add(mTotalCompareBtn);
                mTotalCompareBtn.setText("Total Compare");
                mTotalCompareBtn.setPreferredSize(new java.awt.Dimension(124, 24));
            }
            {
                mPhoneTotalStackPowerBtn = new JButton();
                jPanel1.add(mPhoneTotalStackPowerBtn);
                mPhoneTotalStackPowerBtn.setText("Phone Total Stack Power");
            }
            {
                mDevicesPowerButton = new JButton();
                jPanel1.add(mDevicesPowerButton);
                mDevicesPowerButton.setText("Hardware Component Max Power");
                mDevicesPowerButton.setPreferredSize(new java.awt.Dimension(280, 24));
            }
            {
                mCompareAppPowerBtn = new JButton();
                jPanel1.add(mCompareAppPowerBtn);
                mCompareAppPowerBtn.setText("Compare");
            }
        }
        {
            jPanel2 = new JPanel();
            getContentPane().add(jPanel2, "West");
            jPanel2.setBounds(12, 25, 589, 67);
            jPanel2.setLayout(null);
            jPanel2.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mFilePathLabel = new JLabel();
                jPanel2.add(mFilePathLabel);
                mFilePathLabel.setText("File Path");
                mFilePathLabel.setPreferredSize(new java.awt.Dimension(48, 17));
                mFilePathLabel.setBounds(8, 8, 48, 17);
            }
            {
                mFilePathTextField = new JTextField();
                jPanel2.add(mFilePathTextField);
                mFilePathTextField.setText("None");
                mFilePathTextField.setEditable(false);
                mFilePathTextField.setBounds(68, 4, 430, 24);
            }
            {
                mFileBtn = new JButton();
                jPanel2.add(mFileBtn);
                mFileBtn.setText("OPEN");
                mFileBtn.setBounds(503, 6, 81, 24);
            }
            {
                LOGTimeLabel = new JLabel();
                jPanel2.add(LOGTimeLabel);
                LOGTimeLabel.setText("LOG Time");
                LOGTimeLabel.setBounds(8, 37, 60, 17);
            }
            {
                mLogScaleTextFiled = new JTextField();
                jPanel2.add(mLogScaleTextFiled);
                mLogScaleTextFiled.setText("None");
                mLogScaleTextFiled.setEditable(false);
                mLogScaleTextFiled.setBounds(68, 34, 430, 24);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(13, 122, 424, 228);
            {
                listModel = new DefaultListModel();// List? ??  ??.
                mUidList = new JList(listModel);
                mUidList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 
                // ?
                // ?
                // .
                jScrollPane1.setViewportView(mUidList);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

                mUidList.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
                //mUidList.setPreferredSize(new java.awt.Dimension(586, 222));   /?  ?.
            }
        }
        {
            jPanel3 = new JPanel();
            getContentPane().add(jPanel3);
            jPanel3.setBounds(12, 0, 579, 31);
            {
                dd = new JLabel();
                jPanel3.add(dd);
                dd.setText("Power Tutor Trace");
                dd.setPreferredSize(new java.awt.Dimension(106, 17));
            }
        }
        {
            jPanel5 = new JPanel();
            getContentPane().add(jPanel5, "West");
            jPanel5.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel5.setBounds(12, 356, 304, 58);
            jPanel5.setLayout(null);
            {
                Range = new JLabel();
                jPanel5.add(Range);
                Range.setText("Range");
                Range.setBounds(14, 10, 46, 17);
            }
            {
                mFirstRangeText = new JTextField();
                jPanel5.add(mFirstRangeText);
                mFirstRangeText.setBounds(59, 7, 63, 24);
            }
            {
                mUidPieDiagramBtn = new JButton();
                jPanel5.add(mUidPieDiagramBtn);
                mUidPieDiagramBtn.setText("UID Pie");
                mUidPieDiagramBtn.setBounds(207, 7, 90, 24);
            }
            {
                jLabel3 = new JLabel();
                jPanel5.add(jLabel3);
                jLabel3.setText("-");
                jLabel3.setBounds(128, 10, 10, 17);
            }
            {
                mSecondRangeText = new JTextField();
                jPanel5.add(mSecondRangeText);
                mSecondRangeText.setBounds(138, 7, 63, 24);
            }
            {
                mComponentPieBtn = new JButton();
                jPanel5.add(mComponentPieBtn);
                mComponentPieBtn.setText("PHONE Pie");
                mComponentPieBtn.setBounds(59, 36, 238, 16);
            }
        }
        {
            jPanel6 = new JPanel();
            getContentPane().add(jPanel6, "West");
            jPanel6.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel6.setBounds(322, 356, 275, 66);
            jPanel6.setLayout(null);
            {
                jLabel4 = new JLabel();
                jPanel6.add(jLabel4);
                jLabel4.setText("TotalPM");
                jLabel4.setBounds(16, 10, 56, 26);
            }
            {
                mChartMeanUnitTextField = new JTextField();
                jPanel6.add(mChartMeanUnitTextField);
                mChartMeanUnitTextField.setBounds(77, 7, 135, 29);
            }
            {
                m3DBarChartMean = new JButton();
                jPanel6.add(m3DBarChartMean);
                m3DBarChartMean.setText("ok");
                m3DBarChartMean.setBounds(218, 7, 49, 24);
            }
            {
                mAudioCheckBox = new JCheckBox();
                jPanel6.add(mAudioCheckBox);
                mAudioCheckBox.setText("AUDIO");
                mAudioCheckBox.setBounds(79, 40, 65, 21);
            }
            {
                mGPSCheckBox = new JCheckBox();
                jPanel6.add(mGPSCheckBox);
                mGPSCheckBox.setText("GPS");
                mGPSCheckBox.setBounds(151, 40, 56, 21);
            }
        }
        {
            jPanel4 = new JPanel();
            getContentPane().add(jPanel4, "North");
            FlowLayout jPanel4Layout = new FlowLayout();
            jPanel4.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel4.setLayout(jPanel4Layout);
            jPanel4.setBounds(12, 523, 590, 66);
            {
                mAppTotalPowerBtn = new JButton();
                jPanel4.add(mAppTotalPowerBtn);
                mAppTotalPowerBtn.setText("UID Line Total Power");
                mAppTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAppStackedPower = new JButton();
                jPanel4.add(mAppStackedPower);
                mAppStackedPower.setText("UID Stack Total Power");
                mAppStackedPower.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mLedBtn = new JButton();
                jPanel4.add(mLedBtn);
                mLedBtn.setText("UID LED Power");
                mLedBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mCpuBtn = new JButton();
                jPanel4.add(mCpuBtn);
                mCpuBtn.setText("UID CPU Power");
                mCpuBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mWifiBtn = new JButton();
                jPanel4.add(mWifiBtn);
                mWifiBtn.setText("UID WIFI Power");
                mWifiBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                m3GBtn = new JButton();
                jPanel4.add(m3GBtn);
                m3GBtn.setText("UID ThreeG Power");
                m3GBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jPanel7 = new JPanel();
            getContentPane().add(jPanel7, "North");
            FlowLayout jPanel7Layout = new FlowLayout();
            jPanel7.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel7.setLayout(jPanel7Layout);
            jPanel7.setBounds(12, 618, 590, 63);
            {
                mComponentLEDBtn = new JButton();
                jPanel7.add(mComponentLEDBtn);
                mComponentLEDBtn.setText("LED Power");
                mComponentLEDBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentWIFIBtn = new JButton();
                jPanel7.add(mComponentWIFIBtn);
                mComponentWIFIBtn.setText("WIFI Power");
                mComponentWIFIBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mGpsBtn = new JButton();
                jPanel7.add(mGpsBtn);
                mGpsBtn.setText("GPS Power");
                mGpsBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentCPUBtn = new JButton();
                jPanel7.add(mComponentCPUBtn);
                mComponentCPUBtn.setText("CPU Power");
                mComponentCPUBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentThreeGBtn = new JButton();
                jPanel7.add(mComponentThreeGBtn);
                mComponentThreeGBtn.setText("ThreeG Power");
                mComponentThreeGBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAudioBtn = new JButton();
                jPanel7.add(mAudioBtn);
                mAudioBtn.setText("AUDIO Power");
                mAudioBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("Individual App component Power");
            jLabel1.setBounds(12, 506, 202, 17);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("Function Button");
            jLabel2.setBounds(12, 411, 181, 17);
        }
        {
            jLabel5 = new JLabel();
            getContentPane().add(jLabel5);
            jLabel5.setText("Individual H/W Component Power");
            jLabel5.setBounds(12, 601, 223, 17);
        }
        {
            jScrollPane2 = new JScrollPane();
            getContentPane().add(jScrollPane2);
            jScrollPane2.setBounds(493, 122, 108, 194);
            {
                listModelUidDelte = new DefaultListModel();// List? ??  ??.
                mDeleteList = new JList(listModelUidDelte);
                jScrollPane2.setViewportView(mDeleteList);
            }
        }
        {
            mDeleteAllBtn = new JButton();
            getContentPane().add(mDeleteAllBtn);
            mDeleteAllBtn.setText("A");
            mDeleteAllBtn.setBounds(493, 321, 51, 24);
        }
        {
            mDeleteOneBtn = new JButton();
            getContentPane().add(mDeleteOneBtn);
            mDeleteOneBtn.setText("O");
            mDeleteOneBtn.setBounds(549, 321, 48, 24);
        }
        {
            mDeleteUidMoveBtn = new JButton();
            getContentPane().add(mDeleteUidMoveBtn);
            mDeleteUidMoveBtn.setText(">");
            mDeleteUidMoveBtn.setBounds(443, 169, 45, 95);
        }
        {
            jLabel6 = new JLabel();
            getContentPane().add(jLabel6);
            jLabel6.setText("Package Name List");
            jLabel6.setBounds(13, 99, 139, 17);
        }
        {
            jLabel7 = new JLabel();
            getContentPane().add(jLabel7);
            jLabel7.setText("Remove Uid");
            jLabel7.setBounds(493, 100, 139, 17);
        }
        pack();
        this.setSize(623, 725);
        // setVisible(true);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:mod.steps.stepmode.threads.forms.TransitionsChooser.java

private void initializeList() {
    try {/*from  w w w .  j  a  v a  2 s .  c o m*/
        this.listModel = new DefaultListModel();
        for (TransitionsList list : dataToChooseFrom) {
            listModel.addElement(list.toListElement(options));
        }
        this.listTransitionsCombinations.setModel(listModel);
    } catch (Exception ex) {
    } finally {
        this.listTransitionsCombinations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

private void transitionListInitializations() {
    listTransition = new JList();
    listTransition.setCellRenderer(new coloredMRMListRenderer());
    listTransition.setModel(new DefaultListModel());
    listTransition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _tlsl = new transitionListSelectionListener();
    listTransition.addListSelectionListener(_tlsl);
    listTransition.addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent event) {
            int move = event.getWheelRotation();
            int curIndex = listTransition.getSelectedIndex();
            int newIndex = curIndex;
            if (move > 0) {
                newIndex = Math.min(curIndex + move, listTransition.getModel().getSize());
                listTransition.setSelectedIndex(newIndex);
            }// ww  w.  j  av  a  2 s  .  c o  m
            if (move < 0) {
                newIndex = Math.max(curIndex + move, 0);
                listTransition.setSelectedIndex(newIndex);
            }
            listTransition.ensureIndexIsVisible(newIndex);
        }
    });

    for (MRMTransition curTran : _mrmTransitions)
        ((DefaultListModel) listTransition.getModel()).addElement(curTran);
    listTransition.setVisible(true);
    listScrollPane.getViewport().setView(listTransition);
    listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    listScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent ae) {
            if (!ae.getValueIsAdjusting()) {
                listTransition.repaint();
            }
        }
    });
}

From source file:edu.umn.natsrl.ticas.plugin.srte.SRTEMainPanel.java

/**
 * Load eventlist info//from   w  ww  .ja v  a  2 s  . c o  m
 */
private void setEventListinfo() {
    selectedEventList = (TimeEventLists) this.cbxeventlists.getSelectedItem();
    DefaultListModel dm = new DefaultListModel();

    if (selectedEventList == null)
        return;

    for (TimeEvent te : selectedEventList.getTimeEvents()) {
        dm.addElement(te);
    }
    //        _list.setModel(dm);
    lbxeventlist.setModel(dm);
}

From source file:ca.sqlpower.swingui.enterprise.client.ServerProjectsManagerPanel.java

/**
 * Creates a dialog that lets the user choose a server connection and then a
 * project./*  w w w.java 2 s.c  om*/
 * 
 * @param serverManager
 *            This object contains all of the server information objects
 *            known and the servers based on their information will be
 *            displayed in a list so a user can navigate to different
 *            projects in different servers.
 * @param dialogOwner
 *            The dialog to parent new dialogs to.
 * @param upf
 *            A user prompter factory for displaying error and warning
 *            messages to users.
 * @param closeAction
 *            An action that will close the dialog or frame that this dialog
 *            is contained in.
 * @param defaultFileDirectory
 *            A default file directory to start looking for files in if the
 *            user wants to upload a project. If null this will default to
 *            the user's home directory.
 * @param cookieStore
 *            A cookie store for HTTP requests. Used by the
 *            {@link ClientSideSessionUtils}.
 */
public ServerProjectsManagerPanel(SPServerInfoManager serverManager, Component dialogOwner,
        UserPrompterFactory upf, Action closeAction, File defaultFileDirectory, CookieStore cookieStore) {
    this.dialogOwner = dialogOwner;
    this.upf = upf;
    this.closeAction = closeAction;
    this.defaultFileDirectory = defaultFileDirectory;
    this.cookieStore = cookieStore;

    cookieStore.clear();

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("pref:grow, 5dlu, pref:grow, 5dlu, pref", "pref, pref, pref"));

    servers = new JList(new DefaultListModel());
    servers.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                refreshInfoList();
            }
        }
    });

    DefaultListModel serversModel = (DefaultListModel) servers.getModel();
    serversModel.removeAllElements();
    if (serverManager.getServers(false).size() > 0) {
        for (SPServerInfo serverInfo : serverManager.getServers(false)) {
            serversModel.addElement(serverInfo);
        }
    } else {
        serversModel.addElement("No Servers");
        servers.setEnabled(false);
    }

    projects = new JList(new DefaultListModel());
    projects.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            refreshPanel();
            if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
                getOpenAction().actionPerformed(null);
            }
        }
    });

    JScrollPane projectsPane = new JScrollPane(projects);
    projectsPane.setPreferredSize(new Dimension(250, 300));

    JScrollPane serverPane = new JScrollPane(servers);
    serverPane.setPreferredSize(new Dimension(250, 300));

    CellConstraints cc = new CellConstraints();
    builder.add(new JLabel("Servers:"), cc.xyw(1, 1, 2));
    builder.add(new JLabel("Projects:"), cc.xyw(3, 1, 2));
    builder.nextLine();
    builder.add(serverPane, cc.xywh(1, 2, 1, 2));
    builder.add(projectsPane, cc.xywh(3, 2, 1, 2));

    DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new FormLayout("pref"));
    buttonBarBuilder.append(new JButton(refreshAction));
    buttonBarBuilder.append(securityButton);
    buttonBarBuilder.append(new JButton(newAction));
    buttonBarBuilder.append(openButton);
    buttonBarBuilder.append(new JButton(uploadAction));
    buttonBarBuilder.append(new JButton(deleteAction));
    buttonBarBuilder.append(new JButton(closeAction));
    builder.add(buttonBarBuilder.getPanel(), cc.xy(5, 2));
    builder.setDefaultDialogBorder();
    panel = builder.getPanel();
}

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 w ww .j  a v  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);
}

From source file:NewApplication.java

private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
    // TODO add your handling code here:

    try {/*from   ww w.j a v  a2s  . c  o  m*/
        ens = JavaApplication.GetEntities();
    } catch (Exception ex) {
    }
    ;

    DefaultListModel list = new DefaultListModel();

    for (Class ent : ens)
        list.addElement(ent.getName());

    listEntities.setModel(list);

}

From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java

private void addVersions(List<JIRAVersionBean> versions) {
    versionsList.removeAll();//  ww w  .  ja v a 2 s  .  c  o  m
    final DefaultListModel listModel = new DefaultListModel();
    for (JIRAVersionBean version : versions) {
        if (version != null && version.getId() != CacheConstants.ANY_ID) {
            listModel.addElement(new VersionWrapper(version));
        }
    }
    versionsList.setModel(listModel);
    versionsList.setEnabled(true);

    createAction.setEnabled(true);
    createAndOpenAction.setEnabled(true);
}