Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4136042

In Graphics class drawArc() and fill3DRect() are not quite right

XMLWordPrintable

    • 2d
    • Fix Understood
    • x86
    • windows_95

      Name: diC59631 Date: 05/07/98


      import java.awt.*;
      import java.awt.event.*;

      public class DrawRectTest extends Frame implements WindowListener {
      public DrawRectTest() {
      super();
      addWindowListener(this);
      }

      public void windowClosing(WindowEvent e) {
      System.exit(0);
      }

      public void windowClosed(WindowEvent e) {}
      public void windowActivated(WindowEvent e) {}
      public void windowDeactivated(WindowEvent e) {}
      public void windowDeiconified(WindowEvent e) {}
      public void windowIconified(WindowEvent e) {}
      public void windowOpened(WindowEvent e) {}

      public void paint(Graphics g ) {
      g.setColor(Color.red);

      // To draw arc starting 0 degree to 1 or 2 degree, I get a whole circle
      g.drawArc(60, 60, 20, 20, 0, -2); // arcAngle = -2 to 2
      g.drawArc(60, 90, 30, 30, 0, -1); // arcAngle = -1 to 1
      g.drawArc(60, 140, 40, 40, 0, -1);
      g.drawArc(60, 200, 50, 50, 0, -1);
      g.drawArc(60, 260, 60, 57, 0, -1);

      // The 3D Rectangle is flipped when given negative width or height, but
      // fillRect() is not like this. Why does it need to change position?

      g.fillRect(100, 80, -10, -50);
      g.fillRect(100, 80, 10, 50);
      g.fill3DRect(200, 155, 40, 40, false);
      g.fill3DRect(200, 155, -40, -40, false);
      // g.draw3DRect(200, 100, -200, 400, true);
      // g.fillRoundRect(100, 50, 200, 400, -1000, 100);
      }

      public static void main(String[] args) {
      Frame drawRect = new DrawRectTest();
      drawRect.setSize(200, 200);
      drawRect.show();
      }

      }
      (Review ID: 23948)
      ======================================================================

            Unassigned Unassigned
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: