本文整理汇总了Java中javax.swing.JList.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java JList.addKeyListener方法的具体用法?Java JList.addKeyListener怎么用?Java JList.addKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.addKeyListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ListPanel
import javax.swing.JList; //导入方法依赖的package包/类
public ListPanel(FilterModel fltrmodel, Function<T, String> mapper) {
setLayout(new java.awt.BorderLayout());
JScrollPane sp = new javax.swing.JScrollPane();
list = new JList();
list.setModel(fltrmodel);
list.setCellRenderer(new CheckBoxListRenderer(mapper));
sp.setViewportView(list);
add(sp, BorderLayout.CENTER);
list.setSelectionModel(new MultiSelectionModel(this::onSelect));
list.addKeyListener(onDelete());
list.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl A"), "SelectAll");
list.getActionMap().put("SelectAll", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
list.setSelectionInterval(0, list.getModel().getSize() - 1);
}
});
}
示例2: init
import javax.swing.JList; //导入方法依赖的package包/类
private void init() {
JScrollPane pane = new JScrollPane();
list = new JList(dataModel);
list.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_F5) {
try {
data = null;
loadImages();
} catch (IOException e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(null, e1
.getLocalizedMessage());
}
list.setModel(dataModel);
list.updateUI();
}
}
});
list.setCellRenderer(new IconRenderer());
pane.setViewportView(list);
for (int i = 0; i < data.size(); i++) {
}
this.add(pane, BorderLayout.CENTER);
}
示例3: MultiImagePicker
import javax.swing.JList; //导入方法依赖的package包/类
public MultiImagePicker() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
imageList = new JList(imageListElements);
imageList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
showSelected();
}
});
imageList.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
showSelected();
}
}
});
imageList.setVisibleRowCount(4);
imageList.setPrototypeCellValue("Image 999");
imageList.setMinimumSize(imageList.getPreferredSize());
multiPanel.setLayout(cl);
add(multiPanel);
JScrollPane scroll = new ScrollPane(imageList);
scroll.getViewport().setMinimumSize(imageList.getPreferredSize());
add(scroll);
addEntry();
}