本文整理匯總了Java中javax.swing.AbstractListModel類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractListModel類的具體用法?Java AbstractListModel怎麽用?Java AbstractListModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractListModel類屬於javax.swing包,在下文中一共展示了AbstractListModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeList
import javax.swing.AbstractListModel; //導入依賴的package包/類
private JList<String> makeList(final String[][] items, int visibleRows, Container parent) {
JList<String> list = new JList<>(new AbstractListModel<String>() {
/**
*
*/
private static final long serialVersionUID = 6510576197401709714L;
public String getElementAt(int i) {
return items[i][0];
}
public int getSize() {
return items.length;
}
});
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setVisibleRowCount(visibleRows);
parent.add(new JScrollPane(list));
return list;
}
示例2: ScrollBivariatePanel
import javax.swing.AbstractListModel; //導入依賴的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);
}
示例3: setNames
import javax.swing.AbstractListModel; //導入依賴的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);
}
示例4: setNames
import javax.swing.AbstractListModel; //導入依賴的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);
}
示例5: SelectBaseFunctionDialog
import javax.swing.AbstractListModel; //導入依賴的package包/類
public SelectBaseFunctionDialog(GUIFramework framework) {
super(framework.getMainFrame(), true);
setTitle(GlobalResourcesManager.getString("SelectModel"));
result = null;
final List<Qualifier> base = IDEF0Plugin.getBaseQualifiers(framework
.getEngine());
Collections.sort(base, new Comparator<Qualifier>() {
private Collator collator = Collator.getInstance();
@Override
public int compare(Qualifier o1, Qualifier o2) {
return collator.compare(o1.getName(), o2.getName());
}
});
list.setModel(new AbstractListModel() {
@Override
public Object getElementAt(int index) {
return base.get(index);
}
@Override
public int getSize() {
return base.size();
}
});
JScrollPane pane = new JScrollPane();
pane.setViewportView(list);
setMainPane(pane);
pack();
setMinimumSize(getSize());
setLocationRelativeTo(null);
Options.loadOptions(this);
}
示例6: propertyChange
import javax.swing.AbstractListModel; //導入依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent evt) {
final Song[] newQueue = (Song[]) evt.getNewValue();
this.queueList.setModel(new AbstractListModel() {
@Override
public int getSize() {
return newQueue.length;
}
@Override
public Object getElementAt(int index) {
return newQueue[index].getTitle();
}
});
}
示例7: setColumns
import javax.swing.AbstractListModel; //導入依賴的package包/類
public void setColumns(final List<EnumTableColumn<E>> enumColumns) {
columns.clear();
columnIndex.clear();
columnIndex.addAll(enumColumns);
for (EnumTableColumn<E> column : enumColumns) {
columns.put(column.name(), column);
}
jColumnSelection.setModel(new AbstractListModel<EnumTableColumn<E>>() {
@Override
public int getSize() {
return columnIndex.size();
}
@Override
public EnumTableColumn<E> getElementAt(int index) {
return columnIndex.get(index);
}
});
}
示例8: createNamedColorListModel
import javax.swing.AbstractListModel; //導入依賴的package包/類
/**
*
* Creates and returns a listModel with items of type NamedColor.
* @return a ListModel containing items of type NamedColor.
*/
public static ListModel createNamedColorListModel() {
final TableModel wrappee = new AncientSwingTeam();
ListModel model = new AbstractListModel() {
public Object getElementAt(int index) {
return wrappee.getValueAt(index, 2);
}
public int getSize() {
return wrappee.getRowCount();
}
};
return model;
}
示例9: setUp
import javax.swing.AbstractListModel; //導入依賴的package包/類
@Override
protected void setUp() throws Exception {
super.setUp();
sortableTableModel = new AncientSwingTeam();
listModel = new AbstractListModel() {
public int getSize() {
return sortableTableModel.getRowCount();
}
public Object getElementAt(int index) {
return sortableTableModel.getValueAt(index, 0);
}
};
treeTableModel = new FileSystemModel();
foregroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null,
Color.MAGENTA);
backgroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW,
null);
}
示例10: testFindPanelFirstRowBackwards
import javax.swing.AbstractListModel; //導入依賴的package包/類
/**
* Issue #236-swingx: backwards match in first row shows not-found-message.
* Trackdown from Nicfagn - findPanel.doSearch always returns the next startIndex
* in backwards search that's -1 which is interpreted as "not-found"
*
*/
public void testFindPanelFirstRowBackwards() {
JXList list = new JXList( new AbstractListModel() {
private String[] data = { "a", "b", "c" };
public Object getElementAt(int index) {
return data[ index ];
}
public int getSize() {
return data.length;
}
});
JXFindPanel findPanel = new JXFindPanel(list.getSearchable());
findPanel.init();
PatternModel patternModel = findPanel.getPatternModel();
patternModel.setBackwards(true);
patternModel.setRawText("a");
int matchIndex = list.getSearchable().search(patternModel.getPattern(),
patternModel.getFoundIndex(), patternModel.isBackwards());
assertEquals("found match", matchIndex, findPanel.doSearch());
}
示例11: ItemFilterPanel
import javax.swing.AbstractListModel; //導入依賴的package包/類
public ItemFilterPanel() {
setLayout(new BorderLayout(0, 0));
JList<String> list = new JList<String>();
list.setModel(new AbstractListModel<String>() {
private static final long serialVersionUID = 1L;
String[] values = new String[] { "Blah", "Blub", "Dingens" };
public int getSize() {
return values.length;
}
public String getElementAt(int index) {
return values[index];
}
});
add(list, BorderLayout.CENTER);
}
示例12: updateColorList
import javax.swing.AbstractListModel; //導入依賴的package包/類
private void updateColorList(ColorImpressionKnowledge ci) {
final HSVColor[] colors = ci.getColors();
final DefaultListModel<Color> colorListModel = new DefaultListModel<Color>();
for (int i = 0; i < colors.length; i++) {
colorListModel.addElement(colors[i]);
}
colorList.setModel(colorListModel);
final String[] words = ci.getWords();
csList.setCellRenderer(new ImpressionWordListCellRenderer(ci, 14f));
csList.setModel(new AbstractListModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public int getSize() {
return words.length;
}
@Override
public String getElementAt(int index) {
return words[index];
}
});
}
示例13: run
import javax.swing.AbstractListModel; //導入依賴的package包/類
@Override
public void run()
{
while(Scanner.status)
{
list.setModel(new AbstractListModel() {
@Override
public int getSize() {
return Loading.viruslist.size();
}
@Override
public Object getElementAt(int index) {
return Loading.viruslist.get(index);
}
});
}
}
示例14: createColorPicker
import javax.swing.AbstractListModel; //導入依賴的package包/類
@Override
protected JComponent createColorPicker() {
List<ColorItem> colors = getColorItems();
JList<ColorItem> view = new JList<>(new AbstractListModel<ColorItem>() {
@Override
public int getSize() {
return colors.size();
}
@Override
public ColorItem getElementAt(int index) {
return colors.get(index);
}
});
view.setCellRenderer(new ColorItemListCellRenderer());
view.addListSelectionListener(e -> {
setSelectedColor(view.getSelectedValue().color);
});
return new JScrollPane(view);
}
示例15: createCenterList
import javax.swing.AbstractListModel; //導入依賴的package包/類
private JComponent createCenterList() {
centerNames = new JList<>(new AbstractListModel<String>() {
@Override
public int getSize() {
return nameProvider.getCenterNames().length;
}
@Override
public String getElementAt(int index) {
return nameProvider.getCenterNames()[index];
}
});
centerNames.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
centerNames.addListSelectionListener(new CenterListSelectionListener(centerNames));
centerNames.setEnabled(false);
final JScrollPane scrollPane = new JScrollPane(centerNames);
scrollPane.setPreferredSize(new Dimension(160, 200));
return scrollPane;
}