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


Java JList.getModel方法代码示例

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


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

示例1: mouseClicked

import javax.swing.JList; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        if (!(e.getSource() instanceof JList)) {
            return;
        }

        queueList = (JList) e.getSource();
        queueListModel = (DefaultListModel) queueList.getModel();
        queueList.requestFocus();

        int nx = e.getX();

        if (nx > 500) {
            nx = nx - popup.getSize().width;
        }
        popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
    }
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:20,代码来源:QueueMenuMouseListener.java

示例2: getListCellRendererComponent

import javax.swing.JList; //导入方法依赖的package包/类
@Messages({"LBL_RunAllAnalyzers=All Analyzers", "# {0} - the analyzer that should be run", "LBL_RunAnalyzer={0}"})
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (value == null) {
        value = Bundle.LBL_RunAllAnalyzers();
    } else if (value instanceof AnalyzerFactory) {
        value = Bundle.LBL_RunAnalyzer(SPIAccessor.ACCESSOR.getAnalyzerDisplayName((AnalyzerFactory) value));
    } else if (value instanceof Configuration) {
        value = ((Configuration) value).getDisplayName();
    } else if (value instanceof String) {
        setFont(getFont().deriveFont(Font.ITALIC));
        setText((String) value);
        setEnabled(false);
        setBackground(list.getBackground());
        setForeground(UIManager.getColor("Label.disabledForeground"));

        return this;
    }

    if (index == list.getModel().getSize()-5 && list.getModel() instanceof ConfigurationsComboModel && ((ConfigurationsComboModel) list.getModel()).canModify()) {
        setBorder(new Separator(list.getForeground()));
    } else {
        setBorder(null);
    }

    return super.getListCellRendererComponent(list, (indent ? "  " : "") + value, index, isSelected, cellHasFocus);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:RunAnalysisPanel.java

示例3: reloadField

import javax.swing.JList; //导入方法依赖的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

示例4: getMaximumIndex

import javax.swing.JList; //导入方法依赖的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

示例5: getListCellRendererComponent

import javax.swing.JList; //导入方法依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Table table = null;
    Object displayName = null;
    boolean referenced = false;
    TableClosure tableClosure = null;

    if (value instanceof Table) {
        table = (Table)value;
        displayName = table.getName();

        if (list.getModel() instanceof SelectedTablesModel) {
            SelectedTablesModel model = (SelectedTablesModel)list.getModel();
            tableClosure = model.getTableClosure();
            referenced = tableClosure.getReferencedTables().contains(table);
        }
    } else {
        displayName = value;
    }

    JLabel component = (JLabel)super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
    component.setEnabled(!referenced);
    component.setToolTipText(referenced ? getTableTooltip(table, tableClosure) : null); // NOI18N

    return component;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TableUISupport.java

示例6: getMinimumIndex

import javax.swing.JList; //导入方法依赖的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: exportDone

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void exportDone(JComponent source, Transferable data,
                          int action) {
    try {
        if (source instanceof JList && action == MOVE) {
            JList stopList = (JList)source;
            DefaultListModel listModel
                = (DefaultListModel)stopList.getModel();
            for (Object o : (List) data.getTransferData(STOP_FLAVOR)) {
                listModel.removeElement(o);
            }
        }
    } catch (Exception e) {
        logger.warning(e.toString());
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:20,代码来源:TradeRouteInputPanel.java

示例8: actionPerformed

import javax.swing.JList; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JList list = (JList) e.getSource();
       int index = list.getSelectedIndex();
       if (index < 0)
           return;
       CheckListModel model = (CheckListModel) list.getModel();
       model.setChecked(index, !model.isChecked(index));
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CheckList.java

示例9: exportDone

import javax.swing.JList; //导入方法依赖的package包/类
@Override
public void exportDone(JComponent comp, Transferable trans, int action) {
    if (action == MOVE) {
        final JList from = (JList) comp;
        final DefaultListModel model = (DefaultListModel) from.getModel();
        for (int i=indices.length-1; i>=0; i--) {
            model.removeElementAt(indices[i]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FolderList.java

示例10: initList

import javax.swing.JList; //导入方法依赖的package包/类
private void initList(JList l, String val) {
    StringTokenizer tukac = new StringTokenizer(val, ", ");
    DefaultListModel m = (DefaultListModel)l.getModel();
    while (tukac.hasMoreTokens()) {
        String s = tukac.nextToken();
        if (s.isEmpty()) {
            continue;
        }
        m.addElement(s);
    }
    prefs.put(UseSpecificCatch.OPTION_EXCEPTION_LIST, val);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:UseSpecificCatchCustomizer.java

示例11: javaCompletionExcluderEditButtonActionPerformed

import javax.swing.JList; //导入方法依赖的package包/类
private void javaCompletionExcluderEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderEditButtonActionPerformed
    JList list = getSelectedExcluderList();
    int index = list.getSelectedIndex();
    if (index == -1)
    return;
    DefaultListModel model = (DefaultListModel) list.getModel();
    javaExcluderEditing = (String) model.getElementAt(index);
    openExcluderEditor();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CodeCompletionPanel.java

示例12: getBuildableTypes

import javax.swing.JList; //导入方法依赖的package包/类
private List<BuildableType> getBuildableTypes(JList<? extends BuildableType> list) {
    List<BuildableType> result = new ArrayList<>();
    if (list == null) return result;
    ListModel<? extends BuildableType> model = list.getModel();
    for (int index = 0; index < model.getSize(); index++) {
        result.add(model.getElementAt(index));
    }
    return result;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:10,代码来源:BuildQueuePanel.java

示例13: createTransferable

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Transferable createTransferable(JComponent c) {
    JList list = (JList)c;
    DefaultListModel model = (DefaultListModel)list.getModel();
    List<TradeRouteStop> stops = new ArrayList<>();
    for (int index : list.getSelectedIndices()) {
        stops.add((TradeRouteStop)model.get(index));
    }
    return new StopListTransferable(stops);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:14,代码来源:TradeRouteInputPanel.java

示例14: reloadField

import javax.swing.JList; //导入方法依赖的package包/类
private void reloadField (Object component, IssueField field) {
    String newValue;
    if (component instanceof JList) {
        newValue = mergeValues(issue.getFieldValues(field));
    } else {
        newValue = issue.getFieldValue(field);
    }
    boolean fieldDirty = unsavedFields.contains(field.getKey());
    if (!fieldDirty) {
        if (component instanceof JComboBox) {
            JComboBox combo = (JComboBox)component;
            selectInCombo(combo, newValue, true);
        } 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 : issue.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));
        } else if (component instanceof IDEServices.DatePickerComponent) {
            IDEServices.DatePickerComponent picker = (IDEServices.DatePickerComponent) component;
            try {
                picker.setDate(BugzillaIssue.DUE_DATE_FORMAT.parse(newValue));
            } catch (ParseException ex) {
                picker.setDate(null);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:IssuePanel.java

示例15: getMinimumIndex

import javax.swing.JList; //导入方法依赖的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:FreeCol,项目名称:freecol,代码行数:10,代码来源:UnitType.java


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