我正在研究绘制不同形状的绘图小程序.我想在拖动鼠标的同时画线.问题是当线条出现时,它们如下图所示.
我有使用一个点构建的类行(起始点)
并且它有一个名为setDragPoint的方法,它采用鼠标拖动点来绘制线条,同时拖动绘图图像在拖动模式下绘制时会产生太多的闪烁.为什么会这样?
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class PaintBrush extends Applet implements MouseListener, MouseMotionListener {
Shape shape;
Point startPoint;
Point dragPoint;
ArrayList shapes;
Choice shapeChoice;
Choice colorChoice;
Choice fillChoice;
Image drawingImage;
Graphics drawGraphics;
String shapeString, colorString, fillString;
boolean isDragMode;
public void init() {
shapes = new ArrayList();
shapeChoice = new Choice();
shapeChoice.addItem("Line");
shapeChoice.addItem("Rectangle");
shapeChoice.addItem("RoundRect");
shapeChoice.addItem("Oval");
shapeChoice.addItem("FreeHand");
add(shapeChoice);
colorChoice = new Choice();
colorChoice.addItem("Red");
colorChoice.addItem("Green");
colorChoice.addItem("Blue");
add(colorChoice);
fillChoice = new Choice();
fillChoice.addItem("Filled");
fillChoice.addItem("Hollow");
add(fillChoi