SupportWriter space ↗
A JOURNAL ABOUT TECHNOLOGY

Learn something new.
Write. Share.

A space to connect knowledge, one line of code a day.
Discover tutorials, ideas, and notes from a learning journey.

1967 notes & counting ↙
FOR YOUR CURIOSITY

Latest notes.

2D API / NOTES</>↗
2D API21 May 2012

How do I draw an arc in Java 2D?

Arc2D is the abstract superclass for all objects that store a 2D arc defined by a framing rectangle, start angle, angular extent (length of the arc), and a closure type (Arc2D.OPEN, Arc2D.CHORD, or Arc2D.PIE). To constructs a new arc in double values, such as defining the specified location, size, angular extents, and closure type we […]

Wayan · 2 min read
2D API / NOTES</>↗
2D API21 May 2012

How do I draw an ellipse in Java 2D?

The Ellipse2D class define an ellipse that is defined by a framing rectangle. You can create an ellipse using a double or float values. When creating an ellipse using double values use the Ellipse2D.Double class. And for the float values you can use the Ellipse2D.Float class. package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.Ellipse2D; public […]

Wayan · 2 min read
2D API / NOTES</>↗
2D API21 May 2012

How do I draw a GeneralPath in Java 2D?

package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; public class DrawGeneralPath extends JComponent { public static void main(String[] args) { JFrame frame = new JFrame("Draw GeneralPath Demo"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new DrawGeneralPath()); frame.pack(); frame.setSize(new Dimension(420, 400)); frame.setVisible(true); } @Override public void paint(Graphics...

Wayan · 2 min read
2D API / NOTES</>↗
2D API20 May 2012

How do I draw a round rectangle in Java 2D?

The RoundRectangle2D class defines a rectangle with rounded corners defined by a location (x,y), dimension (w x h), and the width and height of an arc with which to round the corners. The RoundRectangle2D.Double class constructs a RoundRectangle2D from the specified values in double, including the location, width and the arch of the round rectangle. […]

Wayan · 1 min read
2D API / NOTES</>↗
2D API20 May 2012

How do I draw a rectangle in Java 2D?

The code snippet below show you how to use the Graphics2D class the draw a rectangle. You can see the snippet in the paintComponent(Graphics g) method defined in the anonymous JPanel object. To draw a rectangle we use the Rectangle2D.Double static-inner class. The constructor of this class accept the information about the rectangle x, y […]

Wayan · 2 min read
2D API / NOTES</>↗
2D API20 May 2012

How do I draw a line in Java 2D?

The following code snippet show you how to draw a simple line using Graphics2D.draw() method. This method take a parameter that implements the java.awt.Shape interface. To draw a line we can use the Line2D.Double static-inner class. This class constructor takes four integers values that represent the start (x1, y1) and end (x2, y2) coordinate of […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.