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

fp.bugs 3346 bounds() from an object which extend Canvas returns incorrect x,y

XMLWordPrintable

    • 1.0.2
    • sparc
    • solaris_2.5
    • Verified

       
      From: ###@###.### (D Trumble)
      This does not look like form output to me.


      Products & Versions
      I am using the JDK 1.0 with NT3.51 and have problems with both the
      Appletviewer and Netscape 2.0Beta6a.

      Short Description
      The call bounds() from an object which extend Canvas returns incorrect
      values of x and y (width and height are correct).

      With the enclosed test code I get the following results:

      Appletviewer shows

      1. tz.htm1 correctly, x = 0 , y = 23, width = 400, height = 277
      2. tz1.html incorrectly, x = 104, y = 92, width = 400, height = 300

      Netscape 2.0Beta3 shows

      1. tz.html correctly, x=0, y = 23, width = 400, height = 277
      2. tz1.html correctly, x=0, y = 0, width = 400, height = 300

      Netscape 2.0Beta6a shows
      1. tz.html incorrectly, x = 14, y = 157, width = 400, height = 277
      2. tz1.html incorrectly, x = 14, y = 134, width = 400, height = 300

        tz.html
      <HTML> <HEAD><TITLE>Example</TITLE></HEAD>
      <BODY>
      <applet code=tz.class width=400 height=300>
      </applet>
      </BODY> </HTML>
      tz.html

        tz1.html
      <HTML> <HEAD><TITLE>Example</TITLE></HEAD>
      <BODY>
      <applet code=tz1.class width=400 height=300>
      </applet>
      </BODY> </HTML>

        tz.java
      import java.awt.*;
      import java.applet.*;
      public class tz extends Applet {
            GD graph;
            public void init() {
              Label tst = new Label("Test");
              graph = new GD();
              setLayout( new BorderLayout() );
              add("North",tst);
              add("Center", graph);
            }
      }

        tz1.java
      import java.awt.*;
      import java.applet.*;
      public class tz1 extends Applet {
            GD graph;
            public void init() {
              graph = new GD();
              setLayout( new BorderLayout() );
              add("Center", graph);
            }
      }

        GD.java
      import java.awt.*;
      import java.applet.*;
      public class GD extends Canvas {
          public void paint(Graphics g) {
              Graphics lg = g.create();
              Rectangle r = bounds();

              System.out.println("R: x = "+r.x+" y = "+r.y);
              System.out.println(" width = "+r.width+" height = "+r.height);

              int border = 30;
              r.x += border;
              r.y += border;
              r.width -= 2*border;
              r.height -= 2*border;
              lg.drawRect(r.x,r.y,r.width,r.height);
              lg.dispose();
          }
      }

      If I am completely out to lunch here, I would really like to know.

      Dave



       




        David Trumble
        Off: (423) 694-8132
        Cel: (423) 207-4472
        Fax: (423) 694-9467
        e-mail: ###@###.###

            tballsunw Tom Ball (Inactive)
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: