Java Code Examples for javax.swing.DefaultListModel#addElement()
The following examples show how to use
javax.swing.DefaultListModel#addElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoarPreferencePanel.java From Spark with Apache License 2.0 | 6 votes |
private void toggleDifferentSettingsForGroup(boolean isSelected) { DefaultListModel<ColorTypes> model = (DefaultListModel<ColorTypes>) _singleColorlist.getModel(); JTextField duration = retrieveComponent("group.duration", JTextField.class); if (isSelected) { if (!model.contains(ColorTypes.BACKGROUNDCOLOR_GROUP)) { model.addElement(ColorTypes.BACKGROUNDCOLOR_GROUP); model.addElement(ColorTypes.HEADERCOLOR_GROUP); model.addElement(ColorTypes.TEXTCOLOR_GROUP); } duration.setEnabled(true); } else { model.removeElement(ColorTypes.BACKGROUNDCOLOR_GROUP); model.removeElement(ColorTypes.HEADERCOLOR_GROUP); model.removeElement(ColorTypes.TEXTCOLOR_GROUP); duration.setEnabled(false); duration.setText(_duration.getText()); } }
Example 2
Source File: DescriptionInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private NoteInfoPane createNotePane(NoteItem note, CharacterFacade character, DefaultListModel<PageItem> listModel, List<NoteInfoPane> notePaneList, int pos) { NoteInfoPane notePane = new NoteInfoPane(note); PageItem pageItem = new PageItem(character, note, notePane); if (pos >= 0 && pos < notePaneList.size()) { // List model also has the portrait etc tabs, so we have to skip over those. listModel.insertElementAt(pageItem, pos + NUM_NON_NOTE_NODES); notePaneList.add(pos, notePane); } else { listModel.addElement(pageItem); notePaneList.add(notePane); } return notePane; }
Example 3
Source File: RadVizPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void setPlotColumn(int index, boolean plot) { if (plot) { this.colorColumn = index; } else { this.colorColumn = -1; } // ignore list DefaultListModel<String> ignoreModel = (DefaultListModel<String>) ignoreList.getModel(); ignoreModel.clear(); for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) { if (i == this.colorColumn) { continue; } ignoreModel.addElement(this.dataTable.getColumnName(i)); } repaint(); }
Example 4
Source File: ProjectInfoPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates new form ProjectInfoPanel */ @NbBundle.Messages("TXT_rootProject=This is a root project.") public ProjectInfoPanel(Project project) { initComponents(); GradleBaseProject gp = GradleBaseProject.get(project); tfProjectFolder.setText(gp.getProjectDir().getAbsolutePath()); tfName.setText(gp.getName()); tfDescription.setText(gp.getDescription()); tfVersion.setText(gp.getVersion()); tfGroup.setText(gp.getGroup()); tfParentProject.setText(gp.isRoot() ? Bundle.TXT_rootProject() : gp.getParentName()); tfParentProject.setEnabled(!gp.isRoot()); DefaultListModel<String> includedBuildModel = new DefaultListModel<>(); for (String includedBuild : gp.getIncludedBuilds().keySet()) { includedBuildModel.addElement(includedBuild); } lsIncludedBuilds.setModel(includedBuildModel); DefaultListModel<String> pluginModel = new DefaultListModel<>(); for (String plugin : gp.getPlugins()) { pluginModel.addElement(plugin); } lsPlugins.setModel(pluginModel); }
Example 5
Source File: ScrTypes.java From PolyGlot with MIT License | 6 votes |
/** * Clears all current types and re-populates values, selecting first value */ private void populateTypes() { try { DefaultListModel<TypeNode> listModel = new DefaultListModel<>(); for (TypeNode curNode : core.getTypes().getNodes()) { listModel.addElement(curNode); } lstTypes.setModel(listModel); lstTypes.setSelectedIndex(0); lstTypes.ensureIndexIsVisible(0); } catch (Exception e) { IOHandler.writeErrorLog(e); InfoBox.error("Type Population Error", "Unable to populate types: " + e.getLocalizedMessage(), core.getRootWindow()); } }
Example 6
Source File: CfgPropsDialog.java From nb-springboot with Apache License 2.0 | 6 votes |
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); } } else { dlmCfgProps.addElement(item); } } } lCfgProps.setModel(dlmCfgProps); if (!dlmCfgProps.isEmpty()) { lCfgProps.setSelectedIndex(0); } }
Example 7
Source File: GrailsCommandChooser.java From netbeans with Apache License 2.0 | 6 votes |
/** Refreshes Rake tasks list view. */ private void refreshTaskList() { String filter = rakeTaskField.getText().trim(); DefaultListModel model = new DefaultListModel(); List<GrailsCommand> matching = Filter.getFilteredTasks(allTasks, filter); for (GrailsCommand task : matching) { model.addElement(task); } matchingTaskList.setModel(model); if (model.isEmpty()) { model.addElement(NO_TASK_ITEM); } matchingTaskList.setSelectedIndex(0); initTaskParameters(); }
Example 8
Source File: FrmPluginManager.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
private void updatePluginCheckList() { DefaultListModel listModel = new DefaultListModel(); for (Plugin plugin : _plugins) { listModel.addElement(new CheckBoxListEntry(plugin, plugin.isLoad())); } this.checkBoxList_Plugin.setModel(listModel); }
Example 9
Source File: RemoveSurroundingCodePanel.java From netbeans with Apache License 2.0 | 5 votes |
private DefaultListModel createModel(List<? extends CodeDeleter> deleters) { DefaultListModel model = new DefaultListModel(); for (CodeDeleter generator : deleters) { model.addElement(generator); } return model; }
Example 10
Source File: ClipboardImportPanel.java From netbeans with Apache License 2.0 | 5 votes |
private ListModel createImportListModel() { DefaultListModel m = new DefaultListModel(); for (String fqn : fqns) { m.addElement(fqn); } return m; }
Example 11
Source File: EarProjectPropertiesTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testResolveProjectDependencies() throws Exception { int countBefore = EarProjectProperties.getJarContentAdditional(earProject).size(); DefaultListModel l = earProjectProperties.EAR_CONTENT_ADDITIONAL_MODEL.getDefaultListModel(); l.remove(l.indexOf(getEjbProject())); earProjectProperties.store(); EditableProperties ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory()); String ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY); assertNull("ejb reference should not exist", ejbReferenceValue); String carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY); assertEquals("car reference should exist", CAR_REFERENCE_EXPECTED_VALUE, carReferenceValue); assertEquals("wrong count of project references", countBefore - 1, EarProjectProperties.getJarContentAdditional(earProject).size()); assertEquals("wrong count of project references", countBefore - 1, earProject.getReferenceHelper().getRawReferences().length); // remove all entries l.clear(); earProjectProperties.store(); assertEquals("wrong count of project references", 0, EarProjectProperties.getJarContentAdditional(earProject).size()); // add new project/module l.addElement(getWebProject()); earProjectProperties.store(); ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory()); ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY); assertNull("ejb reference should not exist", ejbReferenceValue); carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY); assertNull("car reference should not exist", carReferenceValue); String webReferenceValue = ep.getProperty(WEB_REFERENCE_EXPECTED_KEY); assertEquals("web reference should exist", WEB_REFERENCE_EXPECTED_VALUE, webReferenceValue); assertEquals("wrong count of project references", 1, EarProjectProperties.getJarContentAdditional(earProject).size()); assertEquals("wrong count of project references", 1, earProject.getReferenceHelper().getRawReferences().length); }
Example 12
Source File: ScrLogoDetails.java From PolyGlot with MIT License | 5 votes |
/** * Populates logographs based on iterator * * @param logoNodes all logographs to populate */ private void populateLogographs(LogoNode[] logoNodes) { DefaultListModel<Object> logoModel = new DefaultListModel<>(); for (LogoNode curNode : logoNodes) { logoModel.addElement(curNode); } curPopulating = true; lstLogos.setModel(logoModel); lstLogos.setSelectedIndex(0); curPopulating = false; }
Example 13
Source File: FontChooser.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
/** * Set the value of a JList * * @param list JList component * @param values Array of string values */ private void setListValues(JList<String> list, String[] values) { list.removeAll(); DefaultListModel<String> listModel = new DefaultListModel<String>(); for (String value : values) { listModel.addElement(value); } list.setModel(listModel); }
Example 14
Source File: MuleModulesCheckBoxList.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
public void setModules(Collection<Module> modules) { DefaultListModel<JCheckBox> myModel = (DefaultListModel<JCheckBox>)getModel(); for (Module module : modules) { if (!containsModule(module.getName())) { JCheckBox cb = new JCheckBox(module.getName()); myModel.addElement(cb); } } }
Example 15
Source File: SearchPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Returns the {@code ListModel} for the given libraries. * * @param libraries libraries for which to return the model. * @return {@code ListModel} for the given libraries. */ private ListModel<Library> libraryListModelFor(Library[] libraries) { DefaultListModel<Library> listModel = new DefaultListModel<>(); if (libraries != null) { for (Library library : libraries) { listModel.addElement(library); } } return listModel; }
Example 16
Source File: DeclarationPopup.java From netbeans with Apache License 2.0 | 5 votes |
private ListModel createListModel() { DefaultListModel dlm = new DefaultListModel(); for (AlternativeLocation el: declarations) { dlm.addElement(el); } return dlm; }
Example 17
Source File: IconCellEditor.java From gameserver with Apache License 2.0 | 5 votes |
@Override public Component getTableCellEditorComponentAtModel(JTable table, Object value, boolean isSelected, int row, int column) { this.cellValue = value; DefaultListModel listModel = new DefaultListModel(); // File iconDir = ImageUtil.TMP_ASSETS_ICONS_FILE; // File[] iconFiles = iconDir.listFiles(new FilenameFilter() { // // @Override // public boolean accept(File dir, String name) { // if ( name.endsWith(".png") ) { // return true; // } // return false; // } // }); // for ( int i=0; i<iconFiles.length; i++ ) { // listModel.addElement(iconFiles[i]); // } for ( String iconName : MainFrame.ICON_MAPS.keySet() ) { listModel.addElement(iconName); } ListSelectDialog dialog = new ListSelectDialog(listModel, new IconCellRenderer()); int selectIndex = dialog.getList().getSelectedIndex(); if ( selectIndex > -1 ) { Object selectValue = listModel.get(selectIndex); String iconId = selectValue.toString(); this.cellValue = iconId; table.getModel().setValueAt(cellValue, row, column); } return null; }
Example 18
Source File: ChartPanel.java From pdfxtk with Apache License 2.0 | 5 votes |
public static void main(String[] argv) { DefaultListModel model = new DefaultListModel(); ChartPanel cp = new ChartPanel(model); JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(BorderLayout.CENTER, cp); f.setSize(400, 400); f.show(); for(;;) { model.addElement(new int[] {Util.intRandom(100) - 50, Util.intRandom(100) - 50, Util.intRandom(100) - 50}); Util.delay(1000); } }
Example 19
Source File: ChangesetPickerPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void perform () { try { final DefaultListModel<HgLogMessage> targetsModel = new DefaultListModel<>(); final HgLogMessage displayedRevision = getDisplayedRevision(); if (displayedRevision == null) { if (acceptSelection(NO_REVISION)) { targetsModel.addElement(NO_REVISION); } if (acceptSelection(TIP)) { targetsModel.addElement(TIP); } } else { targetsModel.addElement(displayedRevision); } EventQueue.invokeLater(new Runnable() { @Override public void run () { revisionsComboBox.setModel(targetsModel); if (!targetsModel.isEmpty()) { revisionsComboBox.setSelectedIndex(0); } } }); if (displayedRevision == null) { refreshRevisions(this); } else { EventQueue.invokeLater(new Runnable() { @Override public void run () { revisionsComboBox.setSelectedValue(displayedRevision, true); revisionsComboBox.setEnabled(false); panelSearchOptions.setVisible(false); } }); } } finally { initialProgressSupport = null; } }
Example 20
Source File: EditCustomCategoryDialog.java From tda with GNU Lesser General Public License v2.1 | 5 votes |
private void addToList(CustomCategory cat) { DefaultListModel dlm = ((DefaultListModel) catList.getModel()); dlm.ensureCapacity(dlm.getSize() +1); dlm.addElement(cat); catList.ensureIndexIsVisible(dlm.getSize()); }