2D API / CATATAN</>↗2D API22 Mei 2012
To change the color of a graphics shape we can use the setPaint() method. For a simple coloring we can pass the color object into this method, such as Color.RED or Color.GREEN. If you want to paint with a gradient paint you can use the GradientPaint class. This class provides a way to fill a […]
2D API / CATATAN</>↗2D API22 Mei 2012
package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.Line2D; public class DrawStrokeDemo extends JComponent { public static void main(String[] args) { JFrame frame = new JFrame("Draw Stroke Demo"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new DrawStrokeDemo()); frame.pack(); frame.setSize(new Dimension(420, 200)); frame.setVisible(true); } @Override public void paint(Graphics g) { Graphic...
2D API / CATATAN</>↗2D API22 Mei 2012
package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.RoundRectangle2D; public class DrawDashedStroke extends JComponent { public static void main(String[] args) { JFrame frame = new JFrame("Draw Dashed Stroke Demo"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new DrawDashedStroke()); frame.pack(); frame.setSize(new Dimension(420, 250)); frame.setVisible(true); } @Override public void paint(...
2D API / CATATAN</>↗2D API21 Mei 2012
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 […]
2D API / CATATAN</>↗2D API21 Mei 2012
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 […]
2D API / CATATAN</>↗2D API21 Mei 2012
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...