本文整理了Java中javax.swing.JPanel.addKeyListener()
方法的一些代码示例,展示了JPanel.addKeyListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPanel.addKeyListener()
方法的具体详情如下:
包路径:javax.swing.JPanel
类名称:JPanel
方法名:addKeyListener
暂无
代码示例来源:origin: zzz40500/GsonFormat
generateClassP.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent keyEvent) {
代码示例来源:origin: uwolfer/gerrit-intellij-plugin
private void showPopupMenuFromKeyboard() {
myPanel.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(@NotNull KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_DOWN) {
showPopupMenu();
}
}
});
}
代码示例来源:origin: stackoverflow.com
MyKeyEventListener listener = new MyKeyEventListener();
JPanel one = new JPanel();
one.addKeyListener(listener);//method might be wrong
JPanel two = new JPanel();
two.addKeyListener(listener);
listener.addObserver(one);
listener.addObserver(two);
代码示例来源:origin: org.jspresso/jspresso-swing-application
private JComponent createHermeticGlassPane() {
JPanel glassPane = new JPanel();
glassPane.setOpaque(false);
glassPane.addMouseListener(new MouseAdapter() {
// No-op
});
glassPane.addKeyListener(new KeyAdapter() {
// No-op
});
return glassPane;
}
代码示例来源:origin: stackoverflow.com
JPanel panel = new JPanel();
panel.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) { … }
public void keyReleased(KeyEvent e) { … }
public void keyPressed(KeyEvent e) { … }
});
代码示例来源:origin: org.jspresso.framework/jspresso-swing-application
private JComponent createHermeticGlassPane() {
JPanel glassPane = new JPanel();
glassPane.setOpaque(false);
glassPane.addMouseListener(new MouseAdapter() {
// No-op
});
glassPane.addKeyListener(new KeyAdapter() {
// No-op
});
return glassPane;
}
代码示例来源:origin: stackoverflow.com
JPanel p = new JPanel(); //!! This should be a JPanel, not a Panel
p.setFocusable(true); //!! This is needed
p.setLayout(new BorderLayout());
p.addKeyListener(this);
p.requestFocusInWindow();
代码示例来源:origin: stackoverflow.com
public class Test {
public static void main(String[] args) throws InterruptedException {
JFrame f = new JFrame("aaaa");
f.setSize(100, 100);
f.setLocation(100, 100);
JPanel p = new JPanel();
f.add(p);
f.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
System.out.println("pressed");
}
});
p.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
System.out.println("pressed");
}
});
f.setVisible(true);
}
代码示例来源:origin: org.rwshop/org.rwshop.swing.common
private void init(JPanel panel){
myPanel = panel;
myPanel.addMouseListener(this);
myPanel.addMouseWheelListener(this);
myPanel.addKeyListener(this);
}
代码示例来源:origin: org.onebusaway/onebusaway-phone
private static void setupGui(AgiClientScriptImpl script) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
KeyPressHandler handler = new KeyPressHandler(script);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.addKeyListener(handler);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 3));
panel.add(buttonPanel, BorderLayout.CENTER);
String buttons = "123456789*0#";
for (int i = 0; i < buttons.length(); i++)
addButton(buttonPanel, script, handler, buttons.charAt(i));
Document document = script.getDocument();
final JTextArea textArea = new JTextArea(document);
textArea.setEditable(false);
textArea.addKeyListener(handler);
document.addDocumentListener(new ScrollDocumentToEnd(textArea));
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setPreferredSize(new Dimension(300, 100));
scrollPane.addKeyListener(handler);
panel.add(scrollPane, BorderLayout.SOUTH);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: zgqq/mah
@Override
public void init() {
if (init) {
LOGGER.warn("The layout has already been initialized");
return;
}
postPane = PostPaneImpl.instance();
JPanel panel = postPane.getPanel();
panel.addKeyListener(new KeyHandler());
init = true;
}
代码示例来源:origin: girtel/Net2Plan
private static JPanel showAbout() {
final JPanel aboutPanel = new JPanel();
ImageIcon image = new ImageIcon(ImageUtils.readImageFromURL(GUINet2Plan.class.getResource("/resources/gui/logo.png")));
JLabel label = new JLabel("", image, JLabel.CENTER);
aboutPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow]", "[grow][grow]"));
aboutPanel.add(label, "alignx center, aligny bottom, wrap");
aboutPanel.add(new JLabel(ABOUT_TEXT), "alignx center, aligny top");
aboutPanel.setFocusable(true);
aboutPanel.requestFocusInWindow();
aboutPanel.addKeyListener(new KeyAdapter() {
private final int[] sequence = new int[]{KeyEvent.VK_UP, KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, KeyEvent.VK_A, KeyEvent.VK_B};
private int currentButton = 0;
@Override
public void keyPressed(KeyEvent e) {
int keyPressed = e.getKeyCode();
if (keyPressed == sequence[currentButton]) {
currentButton++;
if (currentButton == sequence.length) {
ErrorHandling.setDebug(true);
aboutPanel.removeKeyListener(this);
}
} else {
currentButton = 0;
}
}
});
return aboutPanel;
}
代码示例来源:origin: stackoverflow.com
setContentPane(_contentPane);
_contentPane.setFocusable(true);
_contentPane.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
System.out.println("keyTyped char[" + e.getKeyChar()
代码示例来源:origin: com.github.rjolly/pdf-renderer
ftPanel.addKeyListener(new KeyAdapter() {
代码示例来源:origin: stackoverflow.com
backgroundPanel.addKeyListener(createListener());
this.add(backgroundPanel);
this.setVisible(true);
代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui
this.panel.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
代码示例来源:origin: kaikramer/keystore-explorer
jpDaysOfMonth.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent evt) {
代码示例来源:origin: Syncleus/aparapi
container.addMouseListener(mouseAdaptor);
container.addMouseWheelListener(mouseAdaptor);
container.addKeyListener(keyAdaptor);
container.repaint();
代码示例来源:origin: org.codehaus.izpack/izpack-installer
glassPane.addKeyListener(new KeyAdapter()
代码示例来源:origin: Audiveris/audiveris
/**
* Create a new ShapeBoard object.
*
* @param sheet the related sheet
* @param editor symbols editor, needed for its view
* @param selected true if initially selected
*/
public ShapeBoard (Sheet sheet,
SymbolsEditor editor,
boolean selected)
{
super(Board.SHAPE, null, null, selected, false, false, false);
this.sheet = sheet;
dropAdapter.addDropListener(dropListener);
shapeHistory = new ShapeHistory();
setsPanel = buildSetsPanel();
defineLayout();
// Support for user shape keys
editor.getView().addKeyListener(keyListener);
getComponent().addKeyListener(keyListener);
}
内容来源于网络,如有侵权,请联系作者删除!