javax.swing.JFrame.addKeyListener()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中javax.swing.JFrame.addKeyListener()方法的一些代码示例,展示了JFrame.addKeyListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.addKeyListener()方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:addKeyListener

JFrame.addKeyListener介绍

暂无

代码示例

代码示例来源:origin: kevin-wayne/algs4

/**
 * Adds a {@link DrawListener} to listen to keyboard and mouse events.
 *
 * @param listener the {\tt DrawListener} argument
 */
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: kevin-wayne/algs4

frame.addKeyListener(std);    // JLabel cannot get keyboard focus
frame.setFocusTraversalKeysEnabled(false);  // allow VK_TAB with isKeyPressed()
frame.setResizable(false);

代码示例来源:origin: kevin-wayne/algs4

frame.addKeyListener(this);    // JLabel cannot get keyboard focus
frame.setResizable(false);

代码示例来源:origin: trekawek/coffee-gb

private void startGui() {
  display.setPreferredSize(new Dimension(160 * SCALE, 144 * SCALE));
  mainWindow = new JFrame("Coffee GB: " + rom.getTitle());
  mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  mainWindow.setLocationRelativeTo(null);
  mainWindow.setContentPane(display);
  mainWindow.setResizable(false);
  mainWindow.setVisible(true);
  mainWindow.pack();
  mainWindow.addKeyListener(controller);
  new Thread(display).start();
  new Thread(gameboy).start();
}

代码示例来源:origin: RaiMan/SikuliX2

intro.addKeyListener(new KeyAdapter() {
 @Override
 public void keyTyped(KeyEvent e) {

代码示例来源:origin: RaiMan/SikuliX2

box.addKeyListener(new KeyAdapter() {
 @Override
 public void keyTyped(KeyEvent e) {

代码示例来源:origin: codeminders/javadrone

public KeyboardController(JFrame frame)
{
  frame.addKeyListener(this);
}

代码示例来源:origin: stackoverflow.com

public class MyFrameView {

private JFrame frame;

   MyFrameView(){
    frame = new JFrame();
    frame.addKeyListener(new MyKeyListener());
   }

}

public class MyKeyListener implements KeyListener{

}

代码示例来源:origin: stackoverflow.com

public static void main (String[] args)
 {
   JFrame frame = new JFrame ("Mainframe");
   JComponent test = new Mainframe();
   frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
   frame.setSize (800, 600);
   frame.setFocusable (true);
   frame.getContentPane().setBackground (Color.WHITE);
   frame.getContentPane().add (test);
   frame.addKeyListener ((KeyListener) test);
   frame.setVisible (true);
 }

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  JFrame frame= new JFrame();
  frame.addKeyListener(new KeyAdapter() {

    @Override
    public void keyPressed(KeyEvent e) {
      System.out.println(e.getExtendedKeyCode());
    }            
  });
  frame.setBounds(0, 0, 100, 50);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

AutoClicker clicker = new AutoClicker();
 JFrame frame = new JFrame();
 frame.addKeyListener(clicker);
 frame.setLocationRelativeTo(null);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.setSize(new Dimension(200,300));
 frame.setVisible(true);
 frame.setFocusable(true);
 frame.requestFocus();

代码示例来源:origin: stackoverflow.com

`class mainRun extends JPanel {
public void paintComponent() {//Code In Here}
public static void main(String args[]) {
JFrame frame = new JFrame("Title"); 
//JFrame Code
mainRun mr = new mainRun();
KeyEvent event = new KeyEvent() {
//Default Code
}
frame.add(mr);
frame.addKeyListener(event);
}
}
`

代码示例来源:origin: com.harium.propan/propan-jogl

protected JFrame createFrame(int w, int h) {
      
  JFrame frame = new JFrame();
      
  frame.setSize(w, h);
  frame.setUndecorated(false);
  frame.setTitle(title);
  frame.addWindowListener(buildWindowAdapter());
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.addKeyListener((KeyListener) glCore.getKeyboard());
  
  glCore.setComponent(frame);
  
  //frame.setLocation(p);
  glCore.moveToCenter();
  
  return frame;
}

代码示例来源:origin: com.github.fracpete/princeton-java-stdlib

/*************************************************************************
*  Event-based interactions.
*************************************************************************/
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: com.googlecode.princeton-java-introduction/stdlib

/*************************************************************************
*  Event-based interactions.
*************************************************************************/
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: org.openimaj/sandbox

public HandWritingInputDisplay(double[][] xVals, int[] yVals) {
  this.imageValues = xVals;
  this.numberValues = yVals;
  this.currentImageIndex = 0;
  
  rp = new ResizeProcessor(200, 200);
  JFrame frame = DisplayUtilities.displayName(this.getCurrentImage(), "numbers");
  frame.addKeyListener(this);
}

代码示例来源:origin: openimaj/openimaj

public HandWritingInputDisplay(double[][] xVals, int[] yVals) {
  this.imageValues = xVals;
  this.numberValues = yVals;
  this.currentImageIndex = 0;
  
  rp = new ResizeProcessor(200, 200);
  JFrame frame = DisplayUtilities.displayName(this.getCurrentImage(), "numbers");
  frame.addKeyListener(this);
}

代码示例来源:origin: edu.princeton.cs/algs4

/**
 * Adds a {@link DrawListener} to listen to keyboard and mouse events.
 *
 * @param listener the {\tt DrawListener} argument
 */
public void addListener(DrawListener listener) {
  // ensure there is a window for listenting to events
  show();
  listeners.add(listener);
  frame.addKeyListener(this);
  frame.addMouseListener(this);
  frame.addMouseMotionListener(this);
  frame.setFocusable(true); 
}

代码示例来源:origin: Cool-Coding/remote-desktop-control

/**
 * 初使化主体
 */
private void initBody(){
  imageJpanel=new CanvasPanel();
  jFrame.add(imageJpanel);
  final KeyBoardListener keyBoardListener = new KeyBoardListener(AbstractDisplayPuppet.this);
  final MouseListener mouseListener = new MouseListener(AbstractDisplayPuppet.this);
  jFrame.addKeyListener(keyBoardListener);
  imageJpanel.addMouseListener(mouseListener);
  imageJpanel.addMouseMotionListener(mouseListener);
  imageJpanel.addMouseWheelListener(mouseListener);
}

代码示例来源:origin: openimaj/openimaj

void doWork() throws FileNotFoundException {
  if(printResults != null) {
    resultsFile = new PrintStream(printResults);
  }
  
  // Start a video processor
  selector = new RectangleSelectionListener(this);
  disp = VideoDisplay.createVideoDisplay(source);
  disp.addVideoListener(new TLDVideoListener(this));
  
  JFrame rootScreen = (JFrame) SwingUtilities.windowForComponent(disp.getScreen());
  rootScreen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  rootScreen.addKeyListener(new TLDKeyListener(this));
  disp.getScreen().addMouseListener(selector);
  disp.getScreen().addMouseMotionListener(selector);
}
public void initiateObjectSelect() {

相关文章

JFrame类方法