本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
});
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}