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

Reshaping component in a frame has undesisred effects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1
    • client-libs
    • None
    • x86
    • windows_nt



      Name: el35337 Date: 01/13/97


       Markus Kropf <###@###.###>
      Reshaping a component in a frame which is placed away from the top left
      position of the screen moves the component to the desired coordinate
      plus the frame offset instead of to the desired coordinate only.

      Example program follows; run it standalone under JDK 1.0.2, Windows 95;
      click repaatedly on the rectangle; then move the frame away from the
      top left screen position and see how the rectangle moves at each click.

      -----------------------------------------------------------------------
      import java.awt.*;
      class FlipRect extends Canvas {
        FlipRect(int x, int y, int unit) {
            reshape(x, y, 4*unit, 4*unit);
        }
        public boolean mouseDown(Event evt, int x, int y) {
        Rectangle b = bounds();
        if (b.width >= b.height) {
        reshape(b.x+b.width/4, b.y-b.height/4, b.width/2, 3*b.height/2);
        } else {
            reshape(b.x-b.width/2, b.y+b.height/6, 2*b.width, 2*b.height/3);
            }
        return true;
          }
            public void paint(Graphics g) {
            Rectangle r = g.getClipRect();
            g.fillRect(r.x, r.y, r.width, r.height);
          }
        public static void main(String argv[]) {
        Frame f = new Frame();
        f.reshape(0,0,200,200);
        f.add(new FlipRect(60, 60, 20));
        f.show();
        }
      }
          -----------------------------------------------------------------------

          Markus Kropf (###@###.###)

      ======================================================================

            gsaab Georges Saab
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: