我希望我的 java 程序默认在后台运行,但是使用 keylistener 来调用我的 changewallpaper 类。changewallpaper 类确实有效,但 keylistener 不调用该方法。keyevent 稍后将更改,目前仅用于测试。
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class listener implements KeyListener {
public static void main(String[] args){
}
@Override
public void keyReleased(KeyEvent arg0) {
int key = arg0.getKeyCode();
if (key == KeyEvent.VK_UP) {
changewallpaper.main();
}
}
@Override
public void keyTyped(KeyEvent arg0) {
int key = arg0.getKeyCode();
if (key == KeyEvent.VK_UP) {
changewallpaper.main();
}
}
@Override
public void keyPressed(KeyEvent arg0) {
int key = arg0.getKeyCode();
if (key == KeyEvent.VK_UP) {
changewallpaper.main();
}
}
}