Is there any way to draw a Point on a JPanel using the java.awt.Graphics class? I couldn't find any such method. Well, there are many methods for drawing lines and other shapes, (e.g .drawLine(int x1, int y1, int x2, int y2), but does Graphics lack the implementation to draw the most basic geometrical object?
Yes It does lack it, you're gonna have to use:
.drawLine(x1, y1, x1, y1)
(the same location for both source and destination points)
You can use this:
Graphics2D g2d = (Graphics2D)g;
g2d.drawOval(5, 5, 100, 100);
Or you can check this article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With