Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should use <code>page.fillPoly()</code></p> <pre><code>int[] xPoints = {x1, x2, x3}; int[] yPoints = {y1, y2, y3}; page.fillPoly(xPoints, yPoints, 3); </code></pre> <p>See <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#fillPolygon%28int[],%20int[],%20int%29" rel="nofollow noreferrer">Graphics#fillPoly()</a></p> <p><b>Edit:</b> Try something like this, for an upside-down half-pyramid</p> <pre><code>int x1 = 0; int y1 = 0; int x2 = 100; int y2 = 0; for (int i = 0; i &lt; x2; i++){ g.drawLine(x1, y1, x2, y2); x1 += 1; y1 += 1; y2 += 1; } </code></pre> <p>This hasn't been tested, but I'm assuming at should print something like this</p> <pre><code>-------------- ------------- ------------ // with no spaces of course. ----------- ---------- --------- -------- .. and so on </code></pre> <p>Again this is just a guess.</p> <hr> <p><b>Edit: Tested and Approved :) </b></p> <pre><code>import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class Test extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); int x1 = 0; int y1 = 0; int x2 = 100; int y2 = 0; for (int i = 0; i &lt; x2; i++) { g.drawLine(x1, y1, x2, y2); x1 += 1; y1 += 1; y2 += 1; } } public Dimension getPreferredSize() { return new Dimension(100, 100); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new Test()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } } </code></pre> <p>Result</p> <p><img src="https://i.stack.imgur.com/AQbyW.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload