0

我创建了一个 GlassPane,目的是能够创建一个能够在当前屏幕上进行注释的工具。我目前正在使用一个数组列表来存储要着色的位置的位置。该部分目前运行良好。

现在我试图通过删除部分arrayList 并调用repaint() 来为程序创建一个橡皮擦。

下面是使用 mouseDragged(MouseEvent e) 将点添加到要绘制的点的 arrayList 的代码。

if (GlassPane.locations.size() == 0 || GlassPane.locations.size() == 1) {
    GlassPane.locations.add(MouseInfo.getPointerInfo().getLocation());
    current++;
} 
else {
    double dist = distance(GlassPane.locations.get((int) (current - 1)), MouseInfo.getPointerInfo().getLocation());
    if (dist >= 1) {
        GlassPane.locations.add(MouseInfo.getPointerInfo().getLocation());
        current++;          
    }
}
4

0 回答 0