Java – draw a line between two points
•
Java
Hello
Solution
In swing:
Graphics g; g.drawLine(X1,Y1,X2,Y2);
If you are drawing a JPanel, you usually put this code in the paintcomponent method:
@Override
protected void paintComponent(Graphics g) {
g.drawLine(X1,Y2);
}
To see all the available methods of the graphics class, see JavaDocs
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
