List of usage examples for javax.swing DefaultListModel addElement
public void addElement(E element)
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatDlg.java
/** * @return// w w w .j av a2 s .c om */ protected List<DataObjSwitchFormatter> populateFormatterList() { // list of existing formats DefaultListModel listModel = new DefaultListModel(); // add available data object formatters List<DataObjSwitchFormatter> fmtrs; fmtrs = dataObjFieldFormatMgrCache.getFormatterList(tableInfo.getClassObj()); Collections.sort(fmtrs, new ComparatorByStringRepresentation<DataObjSwitchFormatter>()); for (DataObjSwitchFormatter format : fmtrs) { listModel.addElement(format); //uniqueTitles.add(format.getTitle()); } return fmtrs; }
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. ja v a2 s . com*/ ens = JavaApplication.GetEntities(); } catch (Exception ex) { } ; DefaultListModel list = new DefaultListModel(); for (Class ent : ens) list.addElement(ent.getName()); listEntities.setModel(list); }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
/** * Set the timespans manually e.g. while loading a stored state * * @param pSpans/*from w ww . ja v a 2 s . c om*/ */ public void setTimeSpans(List<TimeSpan> pSpans) { DefaultListModel model = new DefaultListModel(); model.addElement(new TimeSpanDivider()); jTimeFrameList.setModel(model); for (TimeSpan span : pSpans) { addTimeSpan(span); } }
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.//from ww w .j a v a2 s . c o m * * @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:de.tor.tribes.ui.algo.AttackTimePanel.java
public final void reset() { jSendTimeFrame.setMinimumValue(0);//w ww.j ava 2 s . co m jSendTimeFrame.setMaximumColor(Constants.DS_BACK_LIGHT); jSendTimeFrame.setMinimumColor(Constants.DS_BACK_LIGHT); jSendTimeFrame.setMaximumValue(24); jSendTimeFrame.setSegmentSize(1); jSendTimeFrame.setUnit("h"); jSendTimeFrame.setBackground(getBackground()); jSendTimeFrame.setDecimalFormater(new DecimalFormat("##")); DefaultListModel model = new DefaultListModel(); model.addElement(new TimeSpanDivider()); jTimeFrameList.setModel(model); jTimeFrameList.setCellRenderer(new TimeFrameListCellRenderer()); Calendar c = Calendar.getInstance(); minSendTimeField.setDate(c.getTime()); c.setTimeInMillis(System.currentTimeMillis() + DateUtils.MILLIS_PER_HOUR); maxArriveTimeField.setDate(c.getTime()); dateTimeField.setDate(c.getTime()); }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
void loadSrcTextarea() throws IOException { String srcText = null;// w w w . j ava 2s . co m Validate.notEmpty((srcText = srcArea.getText()), "src textarea can't empty"); Validate.notNull(manualBaseDir, "src base directory not set!"); BufferedReader reader = new BufferedReader(new StringReader(srcText)); ParseMode mode = null; LineParser lineParser = null; Set<LineParser> set = new HashSet<LineParser>(); DefaultListModel errorLogModel = new DefaultListModel(); for (String line = null; (line = reader.readLine()) != null;) { mode = ((ParseMode) exportModeCombo.getSelectedItem()); if (mode == null) { continue; } lineParser = mode.parse(line, errorLogModel); System.out.println("lineParser = " + lineParser); if (lineParser != null) { set.add(lineParser); } } errorLogList.setModel(errorLogModel); if (errorLogModel.getSize() != 0) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("same error occor!,\n check out error log panel", "ERROR"); } DefaultListModel srcModel = new DefaultListModel(); for (LineParser line : set) { srcModel.addElement(line); } srcList.setModel(srcModel); copySrcListForQuerySet = Collections.unmodifiableSet(set); }
From source file:gtu._work.ui.CheckJavaClassPathUI.java
private void initGUI() { try {/*from w w w .j a v a 2s . c o m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); setTitle("??importjava"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("", null, jPanel1, null); { classPathText = new JTextField(); jPanel1.add(classPathText, BorderLayout.NORTH); classPathText.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (StringUtils.isNotBlank(classPathText.getText())) { String text = classPathText.getText(); DefaultListModel model = (DefaultListModel) classPathList.getModel(); boolean findOk = false; for (int ii = 0; ii < model.size(); ii++) { String val = (String) model.getElementAt(ii); if (StringUtils.equals(val, text)) { findOk = true; } } if (!findOk) { model.addElement(text); } } } }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(492, 302)); { DefaultListModel classPathListModel = new DefaultListModel(); classPathList = new JList(); Set<String> clzSet = new HashSet<String>(); for (Enumeration<?> enu = configBean.getConfigProp().keys(); enu.hasMoreElements();) { String key = (String) enu.nextElement(); if (key.contains(CLASSNAME_KEY)) { clzSet.add(configBean.getConfigProp().getProperty(key)); } } for (String clzName : clzSet) { classPathListModel.addElement(clzName); } jScrollPane1.setViewportView(classPathList); classPathList.setModel(classPathListModel); classPathList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(classPathList).defaultJListKeyPressed(evt); } }); } } { executeBtn = new JButton(); jPanel1.add(executeBtn, BorderLayout.WEST); executeBtn.setText("\u57f7\u884c"); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { executeBtnActionPerformed(evt); } }); } { srcPathText = new JTextField(); if (configBean.getConfigProp().containsKey(SRCPATHTEXT_KEY)) { srcPathText.setText(configBean.getConfigProp().getProperty(SRCPATHTEXT_KEY)); } jPanel1.add(srcPathText, BorderLayout.SOUTH); JCommonUtil.jTextFieldSetFilePathMouseEvent(srcPathText, true); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("log", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(530, 350)); { logArea = new JTextArea(); jScrollPane2.setViewportView(logArea); } } } } pack(); this.setSize(551, 417); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchRankFrame.java
@Override public void actionPerformed(ActionEvent e) { RankTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);/*from w w w .j av a2s. c o m*/ g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < activeTab.getRankTable().getColumnCount(); i++) { TableColumnExt col = activeTab.getRankTable().getColumnExt(i); if (col.isVisible()) { if (col.getTitle().equals("Name") || col.getTitle().equals("Tag") || col.getTitle().equals("Stamm")) { model.addElement(col.getTitle()); } } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxSearchPane.setVisible(true); } } }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java
void handleSearchResults(ArrayList<ModelIMDbSearchHit> hits) { final DefaultListModel list = new DefaultListModel(); boolean noHits = false; // Error/*from w w w .j a v a2 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:gg.msn.ui.panel.MainPanel.java
public synchronized void updateListWithFACEBOOKContacts() { //fmod.removeAll(); ((DefaultListModel) clientsList.getModel()).removeAllElements(); log.debug("utenti presenti [" + FacebookUserList.buddies.size() + "]"); Iterator<String> it = FacebookUserList.buddies.keySet().iterator(); ArrayList<FacebookUser> offlineUsers = new ArrayList<FacebookUser>(); DefaultListModel listModel = (DefaultListModel) clientsList.getModel(); //prima inserisco nella lista gli elementi online //po tutti quelli offline while (it.hasNext()) { String key = it.next();/*from w w w . j ava 2s. co m*/ log.debug("userID: " + key); FacebookUser fu = FacebookUserList.buddies.get(key); log.debug("status: " + fu.status); if (StringUtils.equals(fu.status, FacebookUser.STATUS_ONLINE)) { listModel.addElement(fu); } else { offlineUsers.add(fu); } } for (FacebookUser facebookUser : offlineUsers) { listModel.addElement(facebookUser); } //clientsList.repaint(); clientsList.validate(); clientsList.repaint(); }