本想用java写一个windows下面的gif录制工具,发现困难重重,先写一个屏幕区域选择框看看。
package screen;
import java.awt.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.Background;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class DraggedRect extends Application {
/**
* 屏幕尺寸
*/
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private int width = (int)screenSize.getWidth();
private int height = (int)screenSize.getHeight();
/**
* 屏幕中心开始,画一个默认的正方形状
*/
private int defaultWidth = 100;
/**
* 默认线条宽度
*/
private int defaultLineWidth = 10;
/**
* 当点击