本文整理匯總了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();
}