key.java

来自「这个文件可以在很短时间里」· Java 代码 · 共 61 行

JAVA
61
字号
package untitled2;import java.awt.*;import java.awt.event.*;import java.applet.*;public class key extends Applet {  int x = 150,y = 150;  boolean isStandalone = false;  BorderLayout borderLayout1 = new BorderLayout();  Panel panel1 = new Panel();  /**Get a parameter value*/  public String getParameter(String key, String def) {    return isStandalone ? System.getProperty(key, def) :      (getParameter(key) != null ? getParameter(key) : def);  }  /**Construct the applet*/  public key() {  }  /**Initialize the applet*/  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  /**Component initialization*/  private void jbInit() throws Exception {    this.setLayout(borderLayout1);    panel1.addKeyListener(new java.awt.event.KeyAdapter() {      public void keyPressed(KeyEvent e) {        panel1_keyPressed(e);      }    });    this.add(panel1, BorderLayout.CENTER);  }  /**Get Applet information*/  public String getAppletInfo() {    return "Applet Information";  }  /**Get parameter info*/  public String[][] getParameterInfo() {    return null;  }  void panel1_keyPressed(KeyEvent e) {        panel1.getGraphics().clearRect(0,0,300,300);    if (e.getKeyCode() == e.VK_LEFT)       x -= 1;    if (e.getKeyCode() == e.VK_RIGHT)       x += 1;    if (e.getKeyCode() == e.VK_UP)       y -= 1;    if (e.getKeyCode() == e.VK_DOWN)       y += 1;    panel1.getGraphics().fillOval(x,y,15,15);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?