本文整理汇总了Java中javax.swing.ListModel.getElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java ListModel.getElementAt方法的具体用法?Java ListModel.getElementAt怎么用?Java ListModel.getElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ListModel
的用法示例。
在下文中一共展示了ListModel.getElementAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例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;
}
示例4: 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;
}
示例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;
}
示例6: 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;
}
示例7: updateListTrechos
import javax.swing.ListModel; //导入方法依赖的package包/类
private void updateListTrechos(RotaVO rota) throws CadastroException {
DefaultListModel<RotaVO> model = new DefaultListModel<RotaVO>();
ListModel<RotaVO> currentModel = this.listTrechos.getModel();
// as rotas precisam ser sequenciais
// logo se a origem da nova rota não for igual ao destino da última,
// lançar exceção
if (currentModel.getSize() > 0) {
RotaVO last = currentModel.getElementAt(currentModel.getSize() - 1);
if (!last.getDescricaoDestino().equals(rota.getDescricaoOrigem()))
throw new CadastroException("Trecho inválido. A próxima rota precisa possuir "
+ last.getDescricaoDestino() + " como origem.");
}
for (int i = 0; i < currentModel.getSize(); i++) {
RotaVO trecho = currentModel.getElementAt(i);
model.addElement(trecho);
}
model.addElement(rota);
this.listTrechos.setModel(model);
}
示例8: getElementAt
import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public Object getElementAt(int index)
{
for( int i = 0; i < models.size(); i++ )
{
ListModel model = models.get(i);
if( model.getSize() <= index )
{
index -= model.getSize();
}
else
{
return model.getElementAt(index);
}
}
return null;
}
示例9: 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();
}
}
示例10: store
import javax.swing.ListModel; //导入方法依赖的package包/类
@Override
public void store() {
/*if (selectedVariablesFormatter != null) {
storeSelectedFormatter(selectedVariablesFormatter);
}*/
Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
ListModel formattersModel = formattersList.getModel();
VariablesFormatter[] formatters = new VariablesFormatter[formattersModel.getSize()];
for (int i = 0; i < formatters.length; i++) {
VariablesFormatter vf = (VariablesFormatter) formattersModel.getElementAt(i);
formatters[i] = vf;
}
p.setArray("VariableFormatters", formatters);
}
示例11: getFiles
import javax.swing.ListModel; //导入方法依赖的package包/类
/**
* Return files currently displayed.
*
* @return an array of items from the file list.
*/
public File[] getFiles() {
waitPainted(-1);
ListModel<?> listModel = getFileList().getModel();
File[] result = new File[listModel.getSize()];
for (int i = 0; i < listModel.getSize(); i++) {
result[i] = (File) listModel.getElementAt(i);
}
return result;
}
示例12: checkItems
import javax.swing.ListModel; //导入方法依赖的package包/类
/**
* Check if Insertcode popup contains requested item
* @param editor Operator of editor window where should Insert Code should be caled
* @param items Expected items
* @return true if all requested item are pressent, to exact match use {@link #containsItems(org.netbeans.jellytools.EditorOperator, java.lang.String[]) containsItems}
*/
public static boolean checkItems(EditorOperator editor, String ... items) {
Set<String> expItems = new HashSet<String>(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);
expItems.remove(cg.getDisplayName());
}
if(!expItems.isEmpty()) return false;
return true;
}
示例13: 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);
}
示例14: getDisplayedGroups
import javax.swing.ListModel; //导入方法依赖的package包/类
String[] getDisplayedGroups() {
ListModel model = displayedGroupsList.getModel();
int n = model.getSize();
String[] groupNames = new String[n];
for (int i = 0; i < n; i++) {
GroupElement ge = (GroupElement) model.getElementAt(i);
groupNames[i] = ge.getGroup().name();
}
return groupNames;
}
示例15: selectTestProject
import javax.swing.ListModel; //导入方法依赖的package包/类
public static void selectTestProject(final BugzillaQuery q) {
QueryPanel qp = (QueryPanel) q.getController().getComponent(QueryMode.EDIT);
ListModel model = qp.productList.getModel();
for (int i = 0; i < model.getSize(); i++) {
QueryParameter.ParameterValue pv = (ParameterValue) model.getElementAt(i);
if (pv.getValue().equals(TEST_PROJECT)) {
qp.productList.setSelectedIndex(i);
break;
}
}
}