Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用GeneralPath绘制两条平行线_Java_Drawing_Java 2d - Fatal编程技术网

Java 如何使用GeneralPath绘制两条平行线

Java 如何使用GeneralPath绘制两条平行线,java,drawing,java-2d,Java,Drawing,Java 2d,我知道我可以使用Line2D。 但是有没有办法用GeneralPathClass画两条平行线呢?可能的话,请找到下面的代码 @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; GeneralPath path = new GeneralPath(); path.moveTo(10, 10); path.lineTo(10, 100

我知道我可以使用
Line2D

但是有没有办法用
GeneralPath
Class画两条平行线呢?

可能的话,请找到下面的代码

@Override
public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D)g;
    GeneralPath path = new GeneralPath();
    path.moveTo(10, 10);
    path.lineTo(10, 100);

    path.moveTo(100, 10);
    path.lineTo(100, 100);

    g2d.draw(path);
}

抱歉,你不能用GeneralPath创建平行线。对不起,我错了。可以使用GeneralPath绘制平行线您还可以
将(line,false)
两个Line2D对象附加到GeneralPath;这也有同样的效果。