import java.awt.*;
import java.awt.event.*;public class Test { public static void main(String[] args) throws AWTException {
// create AWT component
Frame f = new Frame();
// handle component's keyPressed event
f.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ev) {
System.out.println(Character.isUpperCase(
ev.getKeyChar()) ?
"Caps Lock ON" :
"Caps Lock OFF");
}
});
// make component visible (otherwise the Robot won't work)
f.show();
// create Robot
Robot robot = new Robot();
// generate simple caracter key press
robot.keyPress(KeyEvent.VK_A);
}}
import java.awt.event.*;public class Test { public static void main(String[] args) throws AWTException {
// create AWT component
Frame f = new Frame();
// handle component's keyPressed event
f.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ev) {
System.out.println(Character.isUpperCase(
ev.getKeyChar()) ?
"Caps Lock ON" :
"Caps Lock OFF");
}
});
// make component visible (otherwise the Robot won't work)
f.show();
// create Robot
Robot robot = new Robot();
// generate simple caracter key press
robot.keyPress(KeyEvent.VK_A);
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货