开发者

Java applet - mouse and key listener

开发者 https://www.devze.com 2023-01-07 11:57 出处:网络
Is there a way to implement a KeyListener and MouseListener in the same applet? I already tried any ways I thought that wou开发者_高级运维ld work and I tried Google. :\\

Is there a way to implement a KeyListener and MouseListener in the same applet? I already tried any ways I thought that wou开发者_高级运维ld work and I tried Google. :\

my try:

C:\Users\Dan\Documents\DanJavaGen\tileGen.java:23: tileGen is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class tileGen extends JApplet implements KeyListener, MouseListener  {
       ^
1 error


You can certainly implement both KeyListener and MouseListener in the same applet :)

You must have the following methods in the tileGen class:

public void mouseClicked(MouseEvent e) {
}

public void mousePressed(MouseEvent e) {
}

public void mouseReleased(MouseEvent e) {
}

public void mouseEntered(MouseEvent e)b{
}

public void mouseExited(MouseEvent e) {
}

public void keyTyped(KeyEvent e) {
}

public void keyPressed(KeyEvent e) {
}

public void keyReleased(KeyEvent e) {
}

If you already have some of these methods implemented you can leave them out.

Gentle hint: Capitalize your class name as TileGen :) Lower-case class names are — by convention — used only for generated or internal code.

0

精彩评论

暂无评论...
验证码 换一张
取 消