List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:se.trixon.jota.client.ui.editor.TasksPanel.java
private void init() { label.setText(Dict.TASKS.toString()); addButton.setVisible(true);/*from ww w.j a v a 2s . com*/ cloneButton.setVisible(true); editButton.setVisible(true); removeButton.setVisible(true); removeAllButton.setVisible(true); try { DefaultListModel model = new DefaultListModel(); mManager.getServerCommander().getTasks().stream().forEach((task) -> { model.addElement(task); }); setModel(model); } catch (RemoteException ex) { Logger.getLogger(JobsPanel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:se.trixon.solos.core.panel.FilePanel.java
@Override public void onDirRefreshed(final Collection<File> files) { new Thread(new Runnable() { @Override//from www .j a v a 2s . c o m public void run() { DefaultListModel model = new DefaultListModel(); for (File file : files) { model.addElement(file); Solos.log(file.getAbsolutePath()); } mList.setModel(model); } }).start(); }
From source file:seleniumAutomation.flowControls.java
public static LinkedHashMap<String, ArrayList<String>> parseTree(javax.swing.event.TreeSelectionEvent TSE) { testSuite.clear();/*from ww w.j a v a2 s . co m*/ testStep.clear(); parseNodes(((javax.swing.tree.DefaultMutableTreeNode) ((javax.swing.JTree) TSE.getSource()) .getSelectionPath().getLastPathComponent())); Controls.getTestSuite().setModel(new DefaultListModel()); for (String key : testSuite.keySet()) { ((DefaultListModel) Controls.getTestSuite().getModel()).addElement(key); } return testSuite; }
From source file:server.Gui.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* www . j a v a 2s . com*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList<>(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jComboBox1 = new javax.swing.JComboBox<>(); jLabel3 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jButton5 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jList1.setModel(new DefaultListModel()); jScrollPane1.setViewportView(jList1); jButton1.setText("Senden"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel1.setText("Titel:"); jTextField1.setText("Titel"); jLabel2.setText("Text:"); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane2.setViewportView(jTextArea1); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { "Fehler", "Information", "Warnung", "Frage" })); jLabel3.setText("Icon:"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jTextField1) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1).addComponent(jLabel2).addComponent(jLabel3)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE) .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1).addContainerGap())); jTabbedPane1.addTab("Messagebox", jPanel1); jButton2.setText("Herunterfahren"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Neustarten"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setText("Abmelden"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jLabel4.setText("Countdown:"); jTextField2.setText("30"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE) .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextField2))) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4).addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(266, Short.MAX_VALUE))); jTabbedPane1.addTab("System", jPanel2); jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "Eigenschaft", "Wert" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } }); jScrollPane3.setViewportView(jTable1); jButton5.setText("Infos anfordern"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton5) .addGap(0, 16, Short.MAX_VALUE))); jTabbedPane1.addTab("Systeminfo", jPanel3); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTabbedPane1))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1).addComponent(jTabbedPane1)); pack(); }
From source file:sturesy.core.ui.loaddialog.SubsettedJListPair.java
/** * Initialize the SubsettedJListPair with two new DefaultListModels which * are passed to the UI/* w w w . j a v a 2s. com*/ */ public SubsettedJListPair() { _sourceListModel = new DefaultListModel(); _contentListModel = new DefaultListModel(); _ui = new SubsettedJListPairUI(_sourceListModel, _contentListModel); registerListeners(); }
From source file:sturesy.core.ui.loaddialog.TreeListPair.java
public TreeListPair() { _fileTree = new FileTreeController(); _contentListModel = new DefaultListModel(); _ui = new TreeListPairUI(_fileTree.getPanel(), _contentListModel); registerListeners();//from w w w .j av a2 s.co m }
From source file:typoscript.TypoScriptPluginOptions.java
protected void _init() { // Take a copy of the current sites config localSitesConfig = (Vector) TypoScriptPlugin.siteConfig.clone(); listModel = new DefaultListModel(); Iterator iter = localSitesConfig.iterator(); while (iter.hasNext()) { listModel.addElement(iter.next()); }//from ww w . j a v a2 s .c om setLayout(new BorderLayout()); add(BorderLayout.NORTH, new JLabel("TYPO3 Sites")); JPanel sites = new JPanel(new BorderLayout()); siteList = new JList(listModel); siteList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); siteList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); siteList.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { // Edit if doubleclick if (e.getClickCount() == 2) { new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } } public void mouseEntered(MouseEvent e) { ; } public void mousePressed(MouseEvent e) { ; } public void mouseReleased(MouseEvent e) { ; } public void mouseExited(MouseEvent e) { ; } }); JScrollPane scrollPane = new JScrollPane(siteList); sites.add(scrollPane); this.add(sites); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(6, 0, 0, 0)); add = new RolloverButton(GUIUtilities.loadIcon("Plus.png")); add.setToolTipText("Add Site"); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open the add/edit dialog in add mode new AddEditSiteDialog(TypoScriptPluginOptions.this, null); } }); buttons.add(add); remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png")); remove.setToolTipText("Remove Site"); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { localSitesConfig.remove(siteList.getSelectedIndex()); listModel.removeElementAt(siteList.getSelectedIndex()); } }); buttons.add(remove); edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); edit.setToolTipText("Edit Site"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open add/edit dialog in edit mode new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } }); buttons.add(edit); buttons.add(Box.createGlue()); updateButtons(); add(BorderLayout.SOUTH, buttons); }
From source file:ui.panel.UILicenseAdd.java
private JPanel createPnlFeature() { JPanel panel = p.createPanel(Layouts.gridbag); GridBagConstraints g = new GridBagConstraints(); lblSelectFeature = l.createLabel("Select Features", SwingConstants.LEFT); g.gridx = 0;// w ww. j a v a 2s .c o m g.gridy = 0; g.gridwidth = 2; g.insets = new Insets(5, 5, 5, 5); panel.add(lblSelectFeature, g); lblServiceApi = l.createLabel("Service APIs Used", SwingConstants.LEFT); g.gridx = 4; g.gridy = 0; g.gridwidth = 2; g.insets = new Insets(5, 5, 5, 5); panel.add(lblServiceApi, g); getFeaturesData(); DefaultMutableTreeNode root = new MyDataNode("Features", "Features"); for (String key : Data.featureList.keySet()) { try { DefaultMutableTreeNode element = new MyDataNode(key, Data.fieldNames.get(key)); JSONArray features = Data.featureList.get(key); ArrayList<DefaultMutableTreeNode> arrayFeatureCheckBox = new ArrayList<DefaultMutableTreeNode>(); for (int i = 0; i < features.length(); i++) { JSONObject feature = features.getJSONObject(i); DefaultMutableTreeNode featureElement = new MyDataNode((String) feature.get("name"), Data.fieldNames.get(feature.get("name"))); element.add(featureElement); arrayFeatureCheckBox.add(featureElement); } root.add(element); } catch (JSONException e) { e.printStackTrace(); } } tree = new JTree(root); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = tree.getSelectionModel().getSelectionPath(); model.removeAllElements(); String item = tree.getSelectionModel().getSelectionPath().getLastPathComponent().toString(); MyDataNode node = (MyDataNode) tree.getSelectionModel().getSelectionPath().getLastPathComponent(); String selected = node.getValue(); servicesList = new HashMap<String, String>(); try { if (selected.equalsIgnoreCase("Features")) { for (String key : Data.featureList.keySet()) { JSONArray featureArray = Data.featureList.get(key); for (int i = 0; i < featureArray.length(); i++) { JSONArray servicesArray = featureArray.getJSONObject(i).getJSONArray("services"); for (int x = 0; x < servicesArray.length(); x++) { servicesList.put(Integer.toString(servicesArray.getJSONObject(x).getInt("id")), servicesArray.getJSONObject(x).getString("name")); } } } } else if (path.getPathCount() == 2) { for (String key : Data.featureList.keySet()) { if (key.equals(selected)) { JSONArray featureArray = Data.featureList.get(key); for (int i = 0; i < featureArray.length(); i++) { JSONArray servicesArray = featureArray.getJSONObject(i) .getJSONArray("services"); for (int x = 0; x < servicesArray.length(); x++) { servicesList.put( Integer.toString(servicesArray.getJSONObject(x).getInt("id")), servicesArray.getJSONObject(x).getString("name")); } } } else { continue; } } } else { MyDataNode nodePath = (MyDataNode) path.getPathComponent(1); for (String key : Data.featureList.keySet()) { if (key.equals(nodePath.getValue())) { JSONArray featureArray = Data.featureList.get(key); for (int i = 0; i < featureArray.length(); i++) { System.out.println( featureArray.getJSONObject(i).getString("name") + ":" + selected); if (featureArray.getJSONObject(i).getString("name").equals(selected)) { JSONArray servicesArray = featureArray.getJSONObject(i) .getJSONArray("services"); System.out.println(servicesArray); for (int x = 0; x < servicesArray.length(); x++) { servicesList.put( Integer.toString(servicesArray.getJSONObject(x).getInt("id")), servicesArray.getJSONObject(x).getString("name")); } } else { continue; } } } else { continue; } } } } catch (JSONException ex) { ex.printStackTrace(); } for (String serviceKey : servicesList.keySet()) { model.addElement(servicesList.get(serviceKey)); } listServiceUsed.setModel(model); } }); checkTreeManager = new CheckTreeManager(tree); spTreeCheckBox = new JScrollPane(tree); spTreeCheckBox.setPreferredSize(new Dimension(300, 300)); g.gridx = 0; g.gridy = 1; g.gridwidth = 3; g.anchor = g.LINE_START; g.insets = new Insets(5, 5, 5, 5); panel.add(spTreeCheckBox, g); model = new DefaultListModel<>(); model.addElement(""); listServiceUsed = new JList<String>(model); spList = new JScrollPane(listServiceUsed); spList.setPreferredSize(new Dimension(300, 300)); g.gridx = 4; g.gridy = 1; g.gridwidth = 3; g.anchor = g.LINE_START; panel.add(spList, g); return panel; }
From source file:umich.ms.batmass.gui.viewers.map2d.options.Map2DOptionsPanel.java
void load() throws ConfigurationException, IOException { config.clear();/*from w w w. jav a 2s. c o m*/ config = Map2DOptions.getInstance().getConfig(); // the order of adding configurations to combined configuration is important // whoever is added first "shadows" the same key in all subsequently added // configuraions. Thus, add the DEFAULTs at the very end // FileConfiguration userConfig = BmConfig.forClass(BaseMap2D.class); // config.addConfiguration(userConfig); // Configuration defaultConfig = Map2DOptions.getDefaultConfig(); // config.addConfiguration(defaultConfig); checkBoxBasePeak.setSelected(config.getBoolean("doBasePeakMode")); checkBoxInterpRt.setSelected(config.getBoolean("doUpscaling")); checkBoxMzCloseZoomInterp.setSelected(config.getBoolean("doMzCloseZoomGapFilling")); checkBoxProfileModeGapFilling.setSelected(config.getBoolean("doProfileModeGapFilling")); textFieldNumColors.setText(Integer.toString(config.getInt("colorLevels"))); // populating color list colorList.setCellRenderer(new ColorCellRenderer()); colorListModel = new DefaultListModel<>(); Color[] colorsFromConfig = Map2DOptions.getColorsFromConfig(config); for (Color c : colorsFromConfig) { colorListModel.addElement(c); } colorList.setModel(colorListModel); // colorList.setModel(new ColorListModel(getColorsFromConfig(config))); comboIntensityNorm.setSelectedItem(config.getString("intensityNormalizer")); }
From source file:unimelb.distributed_project.gui.JacardSimilarityMeasurePanel.java
/** * Load button's actionPerformed function to load the list of words to find nearest words * against all the words in the list loaded. * * @param e ActionEvent object//from www . ja va2 s . c o m */ private void loadListButtonActionPerformed(ActionEvent e) { JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setCurrentDirectory(new File("/home")); int result = jFileChooser.showOpenDialog(new JFrame()); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = jFileChooser.getSelectedFile(); listOfwordsFilePath = selectedFile.getPath(); File f = new File(listOfwordsFilePath); try { if (f.exists()) { BufferedReader br = new BufferedReader(new FileReader(listOfwordsFilePath)); String line; List<String> lines = new ArrayList<String>(); DefaultListModel model = new DefaultListModel(); while ((line = br.readLine()) != null) { // process the line. lines.add(line); model.addElement(line); log.debug(line); } wordList.setModel(model); wordList.updateUI(); } else { log.debug("Creating file, wordOfList doesn't exist"); } } catch (IOException e1) { log.debug("creating/loading file exception"); e1.printStackTrace(); } log.debug("Selected file: " + listOfwordsFilePath); } else { JOptionPane.showMessageDialog(this.mainFrame, "Please suggest where the listOfWords.txt text file is", "file is not selected", JOptionPane.ERROR_MESSAGE); } }