当前位置: 首页>>代码示例>>Java>>正文


Java ListModel.getSize方法代码示例

本文整理汇总了Java中javax.swing.ListModel.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java ListModel.getSize方法的具体用法?Java ListModel.getSize怎么用?Java ListModel.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ListModel的用法示例。


在下文中一共展示了ListModel.getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updatePrefferedWidth

import javax.swing.ListModel; //导入方法依赖的package包/类
private void updatePrefferedWidth(int firstRow, int lastRow) {
    final ListModel model = getModel();
    final int l = model.getSize() - 1;
    if (lastRow > l)
        lastRow = l;
    if (firstRow < 0)
        firstRow = 0;
    int m = this.m;
    for (int i = firstRow; i <= lastRow; i++) {
        final Object obj = model.getElementAt(i);
        if (obj == null)
            continue;
        final Component c = renderer.getListCellRendererComponent(this,
                obj, i, true, true);
        final int t = c.getPreferredSize().width + 2;
        if (t > m)
            m = t;
    }
    if (m != getFixedCellWidth()) {
        setFixedCellWidth(m);
        revalidate();
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:24,代码来源:TableRowHeader.java

示例2: getModelIndex

import javax.swing.ListModel; //导入方法依赖的package包/类
/**
 * Converts a full index of a list item to the relevant model number. This
 * is required for <code>AttachmentListCellRenderer</code> to display the
 * correct icon.
 * 
 * @see AttachmentListCellRenderer
 * @param index of list item
 * @return index of model used for index parameter
 */
public int getModelIndex(int index)
{
	for( int i = 0; i < models.size(); i++ )
	{
		ListModel model = models.get(i);

		if( model.getSize() <= index )
		{
			index -= model.getSize();
		}
		else
		{
			return i;
		}
	}
	return -1;
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:CombinedListModel.java

示例3: openDialog

import javax.swing.ListModel; //导入方法依赖的package包/类
public boolean openDialog(EditorOperator operator) {
    operator.pressKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();        
    JListOperator list = new JListOperator(jdo);
    ListModel lm = list.getModel();
    for (int i = 0; i < lm.getSize(); i++) {
        CodeGenerator cg  = (CodeGenerator) lm.getElementAt(i);
        if(cg.getDisplayName().equals("Add Property...")) {
            list.setSelectedIndex(i);
            jdo.pushKey(KeyEvent.VK_ENTER);                
            new EventTool().waitNoEvent(250);
            return true;
        }
    }
    fail("Dialog not found");
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:BeansTestCase.java

示例4: reloadField

import javax.swing.ListModel; //导入方法依赖的package包/类
private void reloadField (JComponent component, IssueField field) {
    String newValue;
    newValue = task.getFieldValue(field);
    boolean fieldDirty = unsavedFields.contains(field.getKey());
    if (!fieldDirty) {
        if (component instanceof JComboBox) {
            throw new UnsupportedOperationException();
        } else if (component instanceof JTextComponent) {
            ((JTextComponent) component).setText(newValue);
        } else if (component instanceof JList) {
            JList list = (JList) component;
            list.clearSelection();
            ListModel model = list.getModel();
            for (String value : task.getFieldValues(field)) {
                for (int i = 0; i < model.getSize(); i++) {
                    if (value.equals(model.getElementAt(i))) {
                        list.addSelectionInterval(i, i);
                    }
                }
            }
        } else if (component instanceof JCheckBox) {
            ((JCheckBox) component).setSelected("1".equals(newValue));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TaskPanel.java

示例5: containsItems

import javax.swing.ListModel; //导入方法依赖的package包/类
/**
 * Compares list of items provided in the Insert Code dialog with the list of expected items
 * @param editor Operator of editor window where should Insert Code should be caled
 * @param items Expected items
 * @return true if both list are the same, false otherwise
 */
public static boolean containsItems(EditorOperator editor, String ... items) {
    Set<String> actItems = new HashSet<String>();
    List<String> expItems = Arrays.asList(items);
    editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();        
    JListOperator list = new JListOperator(jdo);
    ListModel lm = list.getModel();
    for (int i = 0; i < lm.getSize(); i++) {
        CodeGenerator cg  = (CodeGenerator) lm.getElementAt(i);
        actItems.add(cg.getDisplayName());
        if(!expItems.contains(cg.getDisplayName())) return false;
    }
    for (String string : expItems) {
        if(!actItems.contains(string)) return false;            
    }
    return true;       
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GenerateCodeOperator.java

示例6: getMinimumIndex

import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public int getMinimumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) {
    ListModel<BuildableType> buildQueue = buildQueueList.getModel();
    BuildingType upgradesFrom = this.getUpgradesFrom();
    if (upgradesFrom == null) return 0;
    Building building = colony.getBuilding(this);
    BuildingType buildingType = (building == null) ? null
            : building.getType();
    if (buildingType == upgradesFrom) return 0;
    for (int index = 0; index < buildQueue.getSize(); index++) {
        if (upgradesFrom.equals(buildQueue.getElementAt(index))) {
            return index + 1;
        }
    }
    return UNABLE_TO_BUILD;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:BuildingType.java

示例7: getMaximumIndex

import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public int getMaximumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) {
    ListModel<BuildableType> buildQueue = buildQueueList.getModel();
    final int buildQueueLastPos = buildQueue.getSize();

    boolean canBuild = false;
    if (colony.canBuild(this)) {
        canBuild = true;
    }

    // does not depend on anything, nothing depends on it
    // can be built at any time
    if (canBuild) return buildQueueLastPos;
    // check for building in queue that allows builting this unit
    for (int index = 0; index < buildQueue.getSize(); index++) {
        BuildableType toBuild = buildQueue.getElementAt(index);
        if (toBuild == this) continue;
        if (toBuild.hasAbility(Ability.BUILD, this)) {
            return buildQueueLastPos;
        }
    }
    return UNABLE_TO_BUILD;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:UnitType.java

示例8: settingChanged

import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public void settingChanged(String generalKey, String specificKey, String value) {
	if (generalKey.equals(this.generalKey)) {
		ListModel listModel = list.getModel();
		// searching indices of selected dimensions
		String names[] = ParameterTypeEnumeration.transformString2Enumeration(value);
		boolean[] selectedDimensions = new boolean[listModel.getSize()];
		for (int i = 0; i < names.length; i++) {
			String name = names[i].trim();
			for (int j = 0; j < listModel.getSize(); j++) {
				if (listModel.getElementAt(j).equals(name)) {
					selectedDimensions[j] = true;
					break;
				}
			}
		}

		// switching all differing dimensions
		setValueIsAdjusting(true);
		for (int i = 0; i < listModel.getSize(); i++) {
			if (selectedDimensions[i]) {
				addSelectionInterval(i, i);
			} else {
				removeSelectionInterval(i, i);
			}
		}
		setValueIsAdjusting(false);
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:ListeningListSelectionModel.java

示例9: getMinimumIndex

import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public int getMinimumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) {
    ListModel<BuildableType> buildQueue = buildQueueList.getModel();
    if (colony.canBuild(this)) return 0;
    for (int index = 0; index < buildQueue.getSize(); index++) {
        if (buildQueue.getElementAt(index).hasAbility(Ability.BUILD, this)) return index + 1;
    }
    return UNABLE_TO_BUILD;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:10,代码来源:UnitType.java

示例10: findItemIndex

import javax.swing.ListModel; //导入方法依赖的package包/类
/**
 * Searches for index'th item good from chooser's point of view.
 *
 * @param chooser Item verifying object.
 * @param index Ordinal item index.
 * @return Item index or -1 if search was insuccessful.
 */
public int findItemIndex(ListItemChooser chooser, int index) {
    ListModel<?> model = getModel();
    int count = 0;
    for (int i = 0; i < model.getSize(); i++) {
        if (chooser.checkItem(this, i)) {
            if (count == index) {
                return i;
            } else {
                count++;
            }
        }
    }
    return -1;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JListOperator.java

示例11: setModel

import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public boolean setModel(
        final ListModel model,
        final boolean finished) {
    called.incrementAndGet();
    symbols.clear();
    for (int i=0; i< model.getSize(); i++) {
        symbols.offer((SymbolDescriptor)model.getElementAt(i));
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ContentProviderImplTest.java

示例12: requestFocusInWindow

import javax.swing.ListModel; //导入方法依赖的package包/类
public boolean requestFocusInWindow() {
    if(this.isOverviewShown && this.entryList != null) {
        ListModel model = this.entryList.getModel();
        if(model != null && model.getSize() > 0) {
            this.entryList.setSelectedIndex(0);
        }

        return this.entryList.requestFocusInWindow();
    } else {
        return this.chooser.requestFocusInWindow();
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:OpenProcessCard.java

示例13: focusOnCar

import javax.swing.ListModel; //导入方法依赖的package包/类
/**
 * Set the car list to select a particular carid if its in the list.
 * @param carid  the id of the car to select
 */
public void focusOnCar(UUID carid)
{
    ListModel<DecoratedCar> lm = cars.getModel();
    for (int ii = 0; ii < lm.getSize(); ii++)
    {
        Car c = (Car)lm.getElementAt(ii);
        if (c.getCarId().equals(carid))
        {
            cars.setSelectedIndex(ii);
            cars.ensureIndexIsVisible(ii);
            break;
        }
    }
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:19,代码来源:DriverCarPanel.java

示例14: getStringArrayValue

import javax.swing.ListModel; //导入方法依赖的package包/类
/** getter for array of Strings
 * @return String[] array of strings from custom editor */    
public String[] getStringArrayValue() {
    ListModel lm=lstItemList().getModel();
    String value[]=new String[lm.getSize()];
    for (int i=0; i<lm.getSize(); i++) {
        value[i]=lm.getElementAt(i).toString();
    }
    return value;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:StringArrayCustomEditorOperator.java

示例15: invokeTemplateAsHint

import javax.swing.ListModel; //导入方法依赖的package包/类
private void invokeTemplateAsHint(EditorOperator editor, final String description) {
    final String blockTemplatePrefix = "<html>Surround with ";

    new EventTool().waitNoEvent(500);
    editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK);
    new EventTool().waitNoEvent(500);
    JListOperator jlo = new JListOperator(MainWindowOperator.getDefault());
    ListModel model = jlo.getModel();
    int i;
    for (i = 0; i < model.getSize(); i++) {
        Object item = model.getElementAt(i);
        String hint = "n/a";
        if (item instanceof SurroundWithFix) {
            hint = ((SurroundWithFix) item).getText();
        }
        if (hint.startsWith(blockTemplatePrefix + description)) {
            System.out.println("Found at "+i+" position: "+hint);
            break;
        }
    }
    if (i == model.getSize()) {
        fail("Template not found in the hint popup");
    }
    new EventTool().waitNoEvent(2000);
    jlo.selectItem(i);
    new EventTool().waitNoEvent(500);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:CodeTemplatesTest.java


注:本文中的javax.swing.ListModel.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。