本文整理汇总了Java中javax.swing.DefaultListModel.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.getSize方法的具体用法?Java DefaultListModel.getSize怎么用?Java DefaultListModel.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browse
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void browse(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browse
try {
final Collection<Integer> added = new ArrayList<>();
final List<? extends String> paths = browseCall.call();
if (paths != null) {
final DefaultListModel<URI> lm = (DefaultListModel<URI>) sources.getModel();
final Set<URI> contained = new HashSet<>(Collections.list(lm.elements()));
int index = sources.getSelectedIndex();
index = index < 0 ? lm.getSize() : index + 1;
for (String path : paths) {
for (URI uri : convertor.call(path)) {
if (!contained.contains(uri)) {
lm.add(index, uri);
added.add(index);
index++;
}
}
}
}
select(added);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
示例2: addJarFiles
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public static int[] addJarFiles( DefaultListModel listModel, int[] indices, String filePaths[], File base,
String[] variables, Callback callback) {
int lastIndex = indices == null || indices.length == 0 ? listModel.getSize() - 1 : indices[indices.length - 1];
int[] indexes = new int[filePaths.length];
for( int i = 0, delta = 0; i+delta < filePaths.length; ) {
int current = lastIndex + 1 + i;
ClassPathSupport.Item item = ClassPathSupport.Item.create( filePaths[i], base, null, variables != null ? variables[i] : null);
if (callback != null) {
callback.initItem(item);
}
if ( !listModel.contains( item ) ) {
listModel.add( current, item );
indexes[delta + i] = listModel.indexOf( item );
i++;
}
else {
indexes[i + delta] = listModel.indexOf( item );
delta++;
}
}
return indexes;
}
示例3: addArtifacts
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public static int[] addArtifacts( DefaultListModel listModel, int[] indices, AntArtifactItem artifactItems[],
Callback callback) {
int lastIndex = indices == null || indices.length == 0 ? listModel.getSize() - 1 : indices[indices.length - 1];
int[] indexes = new int[artifactItems.length];
for( int i = 0; i < artifactItems.length; i++ ) {
int current = lastIndex + 1 + i;
ClassPathSupport.Item item = ClassPathSupport.Item.create( artifactItems[i].getArtifact(), artifactItems[i].getArtifactURI(), null) ;
if (callback != null) {
callback.initItem(item);
}
if ( !listModel.contains( item ) ) {
listModel.add( current, item );
}
indexes[i] = listModel.indexOf( item );
}
return indexes;
}
示例4: addElement
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Adds the element sorted to the model
*
* @param model
* @param element
* @return index of the new element
*/
private int addElement(DefaultListModel<String> model, String element) {
if (model.isEmpty()) {
model.addElement(element);
return 0;
} else {
for (int j = 0; j < model.getSize(); j++) {
int compareValue = String.CASE_INSENSITIVE_ORDER.compare(model.getElementAt(j).toString(), element);
if (compareValue > 0) {
model.add(j, element);
return j;
}
if (j == model.getSize() - 1) {
model.add(j + 1, element);
return j + 1;
}
}
}
// sth went wrong
return -1;
}
示例5: jAddAllOfficesButtonAction
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void jAddAllOfficesButtonAction(java.awt.event.ActionEvent evt) {
DefaultListModel availableModel = (DefaultListModel) jOfficeAvailable.getModel();
DefaultListModel selectedModel = (DefaultListModel) jOfficeSelected.getModel();
for (int i = 0; i < availableModel.getSize(); i++) {
QOffice officeToAdd = (QOffice) availableModel.getElementAt(i);
if (!selectedModel.contains(officeToAdd)) {
selectedModel.addElement(officeToAdd);
officesToAdd.add(officeToAdd);
}
}
//Clear the remove list, since we're adding all of the offices
officesToRemove = new LinkedList<QOffice>();
}
示例6: getIndex
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private int getIndex(DefaultListModel model, String s) {
for (int i = 0; i < model.getSize(); i++) {
ListValue e = (ListValue) model.getElementAt(i);
if(e.value.equals(s)) {
return i;
}
}
return -1;
}
示例7: addURL
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void addURL(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addURL
final NotifyDescriptor.InputLine nd = new NotifyDescriptor.InputLine(
NbBundle.getMessage(SelectRootsPanel.class,"TXT_RemoteJavadoc"),
NbBundle.getMessage(SelectRootsPanel.class,"TXT_RemoteJavadoc_Title"),
NotifyDescriptor.OK_CANCEL_OPTION,
NotifyDescriptor.PLAIN_MESSAGE);
if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
final String inputText = nd.getInputText();
final DefaultListModel<URI> lm = (DefaultListModel<URI>) sources.getModel();
final Set<URI> contained = new HashSet<>(Collections.list(lm.elements()));
int index = sources.getSelectedIndex();
index = index < 0 ? lm.getSize() : index + 1;
try {
URI uri = new URI(inputText);
if (!contained.contains(uri)) {
lm.add(index, uri);
select(Collections.<Integer>singleton(index));
index++;
}
} catch (URISyntaxException ex) {
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
NbBundle.getMessage(SelectRootsPanel.class, "TXT_InvalidRoot", inputText),
NotifyDescriptor.ERROR_MESSAGE));
}
}
}
示例8: formattersMoveDownButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void formattersMoveDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_formattersMoveDownButtonActionPerformed
int index = formattersList.getSelectedIndex();
if (index < 0) return ;
DefaultListModel model = (DefaultListModel) formattersList.getModel();
if (index >= (model.getSize() - 1)) return ;
Object obj = model.remove(index);
model.insertElementAt(obj, index + 1);
formattersList.setSelectedIndex(index + 1);
}
示例9: propertyChange
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent event) {
if(event.getPropertyName().equals("groupRename")) {
String oldGroupName = (String)event.getOldValue();
String newGroupName = (String)event.getNewValue();
DefaultListModel model = (DefaultListModel) groupList.getModel();
for(int i = 0; i < model.getSize(); i++) {
if(((String)model.getElementAt(i)).equals(oldGroupName)) {
model.setElementAt(newGroupName, i);
}
}
}
}
示例10: toTreeModel
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private static DefaultTreeModel toTreeModel(final DefaultListModel lm, final String rootName) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootName);
for (int i = 0; i < lm.getSize(); i++) {
Object obj = lm.getElementAt(i);
if (obj instanceof ClassPathSupport.Item) {
root.add(toTreeNode(obj));
}
}
return new DefaultTreeModel(root);
}
示例11: addButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
int[] indexes = availableGroupsList.getSelectedIndices();
DefaultListModel availableModel = (DefaultListModel) availableGroupsList.getModel();
DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
int at = displayedModel.getSize();
for (int i = indexes.length - 1; i >= 0; i--) {
Object element = availableModel.remove(indexes[i]);
displayedModel.add(at, element);
}
}
示例12: removeButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
int[] indexes = displayedGroupsList.getSelectedIndices();
DefaultListModel availableModel = (DefaultListModel) availableGroupsList.getModel();
DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
int at = availableModel.getSize();
for (int i = indexes.length - 1; i >= 0; i--) {
Object element = displayedModel.remove(indexes[i]);
availableModel.add(at, element);
}
}
示例13: keyStrokeRemoveActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void keyStrokeRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyStrokeRemoveActionPerformed
DefaultListModel lm = (DefaultListModel)shortcutsList.getModel();
Object[] selected = shortcutsList.getSelectedValues();
if (selected.length > 0) {
int idx = shortcutsList.getSelectionModel().getMinSelectionIndex();
for (int i = 0; i < selected.length; i++) {
lm.removeElement(selected[i]);
}
if (lm.getSize() > 0) {
idx = (idx > 0) ? idx -1 : 0;
shortcutsList.setSelectedIndex(idx);
}
}
checkValidity();
}
示例14: importString
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
protected void importString(JComponent c, String str) {
JList target = (JList) c;
DefaultListModel listModel = (DefaultListModel) target.getModel();
int index = target.getSelectedIndex();
// Prevent the user from dropping data back on itself.
// For example, if the user is moving items #4,#5,#6 and #7 and
// attempts to insert the items after item #5, this would
// be problematic when removing the original items.
// So this is not allowed.
if (indices != null && index >= indices[0] - 1 && index <= indices[indices.length - 1]) {
indices = null;
return;
}
int max = listModel.getSize();
if (index < 0) {
index = max;
} else {
index++;
if (index > max) {
index = max;
}
}
addIndex = index;
String[] values = str.split("\n");
addCount = values.length;
for (String value : values) {
listModel.add(index++, value);
}
}
示例15: SaveToFile
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void SaveToFile(DefaultListModel model, String dosyaAdi) throws FileNotFoundException, UnsupportedEncodingException{
PrintWriter writer = new PrintWriter(dosyaAdi, "UTF-8");
try {
int len = model.getSize();
for (int i = 0; i < len; i++) {
writer.println(model.getElementAt(i).toString());
}
} finally {
writer.close();
}
}