❶ 如何在java里添加虛擬鍵盤
設置-程序管理-已安裝的程序-點你想要的程序套件設備*屏幕鍵盤!
❷ java 調用系統虛擬鍵盤
不行,這個做不到,智能手機才可以做到的。不過java程序的特點就在這里,它用虛擬機技術,技術java應用程序出錯也不會對手機底層系統軟體造成影響。
❸ java圖形界面里怎麼做一個虛擬鍵盤
很麻煩,你可以用用載入背景圖片的方式,也可以用按鈕的方式,然後綁定每一個按鈕的事件,反正是各種麻煩
❹ 如何在手機java游戲中插入虛擬鍵盤
給你一個例子,用AWT包可以實現,但是,不知你是要標准26鍵盤,還是手機數字鍵盤:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
/**
*
*/
/**
* @ samuel
*
*/
public class RobotExp {
public static void pressKey(Robot robot, int keyvalue) {
robot.keyPress(keyvalue);
robot.keyRelease(keyvalue);
}
public static void pressKeyWithShift(Robot robot, int keyvalue) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(keyvalue);
robot.keyRelease(keyvalue);
robot.keyRelease(KeyEvent.VK_SHIFT);
}
public static void closeApplication(Robot robot) {
// pressKey(robot, KeyEvent.VK_ALT);
// pressKey(robot, KeyEvent.VK_F4);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_F4);
// for linux.
// robot.keyPress(KeyEvent.VK_ALT);
// robot.keyPress(KeyEvent.VK_W);
// robot.keyRelease(KeyEvent.VK_ALT);
// robot.keyRelease(KeyEvent.VK_W);
robot.keyPress(KeyEvent.VK_N);
robot.keyRelease(KeyEvent.VK_N);
}
public static void main(String[] args) throws IOException {
try {
Robot robot = new Robot();
Runtime.getRuntime().exec("notepad");
// For linux.
// Runtime.getRuntime().exec("gedit");
// 定義5秒的延遲以便你打開notepad 哈哈
// Robot 開始寫
robot.delay(3000);
for (int i = 0; i < 100; i++) {
pressKeyWithShift(robot, KeyEvent.VK_H);
pressKey(robot, KeyEvent.VK_I);
pressKey(robot, KeyEvent.VK_SPACE);
// pressKeyWithShift(robot, KeyEvent.VK_H);
pressKeyWithShift(robot, KeyEvent.VK_I);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_M);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_T);
pressKey(robot, KeyEvent.VK_H);
pressKey(robot, KeyEvent.VK_E);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_J);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_V);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_R);
pressKey(robot, KeyEvent.VK_O);
pressKey(robot, KeyEvent.VK_B);
pressKey(robot, KeyEvent.VK_O);
pressKey(robot, KeyEvent.VK_T);
// VK_ENTER
pressKey(robot, KeyEvent.VK_ENTER);
// pressKey(robot, KeyEvent.);
}
closeApplication(robot);
// robot.keyPress(KeyEvent.VK_SPACE);
} catch (AWTException e) {
e.printStackTrace();
}
}
}