當前位置: 首頁>>代碼示例>>Java>>正文


Java ListModel類代碼示例

本文整理匯總了Java中javax.swing.ListModel的典型用法代碼示例。如果您正苦於以下問題:Java ListModel類的具體用法?Java ListModel怎麽用?Java ListModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ListModel類屬於javax.swing包,在下文中一共展示了ListModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNextMatch

import javax.swing.ListModel; //導入依賴的package包/類
@Override
public int getNextMatch(String prefix, int startIndex, Bias bias) {
    ListModel model = getModel();
    if (!(model instanceof TableModel)) {
        return super.getNextMatch(prefix, startIndex, bias);
    }
    TableModel tablesModel = (TableModel)model;
    int max = tablesModel.getSize();
    int increment = (bias == Bias.Forward) ? 1 : -1;
    int index = startIndex;
    prefix = prefix.toUpperCase();
    do {
        Table table = tablesModel.getElementAt(index);
        String tableName = table.getName().toUpperCase();
        if (tableName.startsWith(prefix)) {
            return index;
        }
        index = (index + increment + max) % max;
    } while (index != startIndex);
    return -1;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:TableUISupport.java

示例2: isChanged

import javax.swing.ListModel; //導入依賴的package包/類
@Override
public boolean isChanged() {
    ListModel formattersModel = formattersList.getModel();
    VariablesFormatter[] formatters = new VariablesFormatter[formattersModel.getSize()];
    for (int i = 0; i < formatters.length; i++) {
        formatters[i] = (VariablesFormatter) formattersModel.getElementAt(i);
    }
    VariablesFormatter[] saved = VariablesFormatter.loadFormatters();
    if(saved == null) {
        return false;
    }
    if(saved.length != formatters.length) {
        return true;
    }
    for (int i = 0; i < saved.length; i++) {
        VariablesFormatter savedFormatter = saved[i];
        VariablesFormatter currentFormatter = (VariablesFormatter) formattersModel.getElementAt(i);
        if(!areVariablesFormattersEqual(savedFormatter, currentFormatter)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:CategoryPanelFormatters.java

示例3: getResult

import javax.swing.ListModel; //導入依賴的package包/類
FixDescription getResult() {
    FixDescription res = new FixDescription();
    res.isSet = addSetCheck.isSelected();
    res.version2Set = res.isSet ? (ArtifactVersion) versionList.getSelectedValue() : null;
    res.isExclude = excludeCheck.isSelected();
    if (res.isExclude) {
        res.exclusionTargets = new HashSet<Artifact>();
        res.conflictParents = new HashSet<MavenDependencyNode>();
        ListModel lm = excludesList.getModel();
        for (int i = 0; i < lm.getSize(); i++) {
            ExclTargetEntry entry = (ExclTargetEntry) lm.getElementAt(i);
            if (entry.isSelected) {
                res.exclusionTargets.add(entry.artif);
                res.conflictParents.addAll(eTargets.getConflictParents(entry.artif));
            }
        }
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:FixVersionConflictPanel.java

示例4: 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:wintertime,項目名稱:FreeCol,代碼行數:24,代碼來源:UnitType.java

示例5: 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

示例6: openDialog

import javax.swing.ListModel; //導入依賴的package包/類
/**
 * Opens requested code generation dialog
 * @param type Displayname of menu item
 * @param editor Operator of editor window where should be menu opened
 * @return true is item is found, false elsewhere
 */
public static boolean openDialog(String type, EditorOperator editor) {
    new EventTool().waitNoEvent(1000);
    editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();
    new EventTool().waitNoEvent(1000);
    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(type)) {
            list.setSelectedIndex(i);
            jdo.pushKey(KeyEvent.VK_ENTER);
            new EventTool().waitNoEvent(1000);
            return true;
        }
    }
    return false;        
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:GenerateCodeOperator.java

示例7: 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

示例8: setModel

import javax.swing.ListModel; //導入依賴的package包/類
/** Sets the model.
 * Threading: Requires EDT.
 * @param the model to set
 * @param finished true for final update
 * @return true if model has changed
 */
@Override
public boolean setModel(
        @NonNull final ListModel model,
        final boolean finished) {
    assert SwingUtilities.isEventDispatchThread();
    matchesList.setModel(model);
    if (model.getSize() > 0 || getText() == null || getText().trim().length() == 0 ) {
        matchesList.setSelectedIndex(0);
        setListPanelContent(null,false);
        if ( time != -1 ) {
            GoToSymbolAction.LOGGER.log(
                    Level.FINE,
                    "Real search time {0} ms.",    //NOI18N
                    (System.currentTimeMillis() - time));
            time = -1;
        }
        return true;
    } else if (finished) {
        setListPanelContent(NbBundle.getMessage(GoToPanelImpl.class, "TXT_NoSymbolsFound") ,false );
        return false;
    } else {
        return false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:GoToPanelImpl.java

示例9: setModel

import javax.swing.ListModel; //導入依賴的package包/類
void setModel(
        @NonNull final ListModel model,
        final boolean done) {
    // XXX measure time here
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            LOG.log(
                Level.FINE,
                "Reset selected items");    //NOI18N
            selectedItems = null;
            resultList.setModel(model);
            if (done) {
                setListPanelContent(null,false);
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:FileSearchPanel.java

示例10: setModel

import javax.swing.ListModel; //導入依賴的package包/類
/** Sets the model from different therad
 */
boolean setModel( final ListModel model) {
    assert SwingUtilities.isEventDispatchThread();
    matchesList.setModel(model);
    if (model.getSize() > 0 || getText() == null || getText().trim().length() == 0 ) {
        matchesList.setSelectedIndex(0);
        setListPanelContent(null,false);
        if ( time != -1 ) {
            GoToTypeAction.LOGGER.fine("Real search time " + (System.currentTimeMillis() - time) + " ms.");
            time = -1;
        }
        return true;
    } else {
        setListPanelContent( NbBundle.getMessage(GoToPanel.class, "TXT_NoTypesFound") ,false ); // NOI18N
        return false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:GoToPanel.java

示例11: setPaidDriverInfo

import javax.swing.ListModel; //導入依賴的package包/類
protected void setPaidDriverInfo()
{
    paidwarning.setOpaque(false);
    paidwarning.setText("");

    if (selectedDriver == null)
        return;

    ListModel<DecoratedCar> m = cars.getModel();
    if (m.getSize() > 0) {
        for (int ii = 0; ii < m.getSize(); ii++) {
            DecoratedCar c = (DecoratedCar)m.getElementAt(ii);
            if (!c.isInRunOrder() && c.hasPaid()) return;
        }
    }

    paidwarning.setText("No cars paid and not in runorder");
    paidwarning.setOpaque(true);
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:20,代碼來源:EntryPanel.java

示例12: invoke

import javax.swing.ListModel; //導入依賴的package包/類
void invoke() {
    int selection = jList1.getSelectedIndex();
    ListModel model = jList1.getModel();
    Object item = model.getElementAt(selection);
    if(item == null) {
        return;
    }
    if(item instanceof PopupItem.IssueItem) {
        IssueImpl issue = ((PopupItem.IssueItem) item).getIssue();
        if (issue != null) {
            comboBar.setIssue(issue);
            clearModel();
        }
    } else {
        PopupItem pitem = (PopupItem) item;
        pitem.invoke();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:QuickSearchPopup.java

示例13: 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:wintertime,項目名稱:FreeCol,代碼行數:17,代碼來源:BuildingType.java

示例14: ScrollBivariatePanel

import javax.swing.ListModel; //導入依賴的package包/類
public ScrollBivariatePanel(JWatBivariateStatsTable table) {
	tab = table;
	setViewportView(tab);
	ListModel lm = new AbstractListModel() {

		private static final long serialVersionUID = 1L;

		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}

	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());
	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
	setRowHeaderView(rowHeader);
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:26,代碼來源:ScrollBivariatePanel.java

示例15: setNames

import javax.swing.ListModel; //導入依賴的package包/類
public void setNames() {
	ListModel lm = new AbstractListModel() {

		private static final long serialVersionUID = 1L;

		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}

	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());
	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
	setRowHeaderView(rowHeader);
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:24,代碼來源:ScrollBivariatePanel.java


注:本文中的javax.swing.ListModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。