About 27,100,000 results
Open links in new tab
  1. java - How to fill color on triangle - Stack Overflow

    Mar 5, 2015 · Make a Polygon from the vertices and fill that instead, by calling fillPolygon(...): // A simple triangle. // vertices. g.fillPolygon(p); // Fills the triangle above. how do you set the color …

  2. Stroking and Filling Graphics Primitives (The Java™ Tutorials > 2D ...

    Using the Java 2D Stroke and Paint classes, you can define fancy line styles and fill patterns. Line styles are defined by the stroke attribute in the Graphics2D rendering context. To set the …

  3. How to Draw a Triangle in Java: An In-Depth Guide and Tutorial

    g.setColor(Color.RED); // set color to red g.drawLine(x1, y1, x2, y2); // draw in red g.setColor(new Color(0, 128, 255)); // custom color g.fillPolygon(coords, 3); // fill blue triangle This renders the …

  4. Class StdDraw - Princeton University

    The second method allows you to specify colors using the Color data type, which is defined in Java's java.awt package. Standard drawing defines a number of predefined colors including …

  5. How to Draw a Triangle in Java - Delft Stack

    Feb 2, 2024 · Use java.awt, javax.swing and drawPolygon to Draw a Triangle in Java. We use JFrame to create a top-level container, and then add a panel, which is our DrawATriangle …

  6. Java Program to Create and Fill Shapes using Applet

    We have to write a program in Java such that it creates the shapes – Square, Pentagon, Circle, Oval, Rectangle and Triangle and fills color inside the shapes.

  7. Shapes and fills in Java 2D - ZetCode

    Jul 17, 2023 · In this part of the Java 2D tutorial, we create some basic and more advanced shapes. We fill shapes with solid colours, gradients, and textures. First we draw some basic …

  8. Drawing with Java: Applying Borders/Outlines to Shapes

    Sep 28, 2016 · After each fillOval, then change Color to Color.BLACK (or whatever outline color you desire), and call drawOval. See what happens to your drawing if you minimize the GUI …

  9. Program to design an applet which display a triangle filled with red ...

    Nov 29, 2016 · A simple program which display a triangle using fillPolygon( ) method with a caption below it. Here, xPoints[ ] array holds the x coordinates and yPoints[ ] array holds the y …

  10. Stroking and Filling Graphics Primitives (The Java™ Tutorials > 2D ...

    Java Tutorials lesson shows how to use the Graphics2D class to draw graphic primitives, arbitrary shapes, and to display graphics with outline and fill styles

Refresh