-1
所以做某些動作的問題我做了一些代碼,截圖功能如何在我的Java項目採取的屏幕截圖
現在這是我做了
public void takeScreenshot() {
try {
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
Point point = window.getLocationOnScreen();
int x = (int)point.getX();
int y = (int)point.getY();
int w = window.getWidth();
int h = window.getHeight();
Robot robot = new Robot(window.getGraphicsConfiguration().getDevice());
Rectangle captureSize = new Rectangle(x, y, w, h);
java.awt.image.BufferedImage bufferedimage = robot.createScreenCapture(captureSize);
int picNumber = random(100);
String fileExtension = "The Iron Door";
File file = new File((new StringBuilder()).append(SignLink.getCacheDirectory() + "Screenshots/" + fileExtension + " ").append(picNumber).append(".png").toString());
ImageIO.write(bufferedimage, "png", file);
} catch(Exception e) {
e.printStackTrace();
}
}
現在的代碼代碼完美的作品我有它設置上做熱鍵的操作,現在我有兩個問題
1)如何將添加某種它周圍的邊框是由我預先製作,並在用戶需要的屏幕截圖將邊框放在圖像上
2)我會怎麼做它使用戶可以輸入他們想要的截圖被稱爲