如题,我希望通过点击一个按钮将panel中的一块指定区域存下来,像是考屏,不过是直接存放在文件中,请问怎么办?

解决方案 »

  1.   

    还有类似于C中的system("pause")的功能在java的console中如何实现?谢谢啦
      

  2.   

    try {
            Robot robot = new Robot();
        
            // Capture a particular area on the screen
            int x = 100;
            int y = 100;
            int width = 200;
            int height = 200;
            Rectangle area = new Rectangle(x, y, width, height);
            BufferedImage bufferedImage = robot.createScreenCapture(area);
        
            // Capture the whole screen
            area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
            bufferedImage = robot.createScreenCapture(area);
        } catch (AWTException e) {
        }
      

  3.   

    可我是希望取panel中的一部分,不是屏幕上啊,是要自己计算吗?