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

Frame.getBounds() returns the wrong position after a resize.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1.6
    • solaris_2.6, 1.1.4, 1.1.5, 1.1.6, 1.2.0
    • client-libs
    • None
    • 1.1.6
    • generic, sparc
    • solaris_2.5.1, solaris_2.6
    • Verified

        Frame.getBounds() returns the wrong position after a resize,
        when the resize changes the upper left corner of the frame.


        // Test3.java:

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

        public class Test3 extends Frame {
            Window w;

            public Test3() {
                final Frame f = this;
                Panel p = new Panel();
                f.add(p);
                p.setLayout(new BorderLayout());
                Button b = new Button("Press");
                b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent be){
                    Component c = (Component)be.getSource();
                    Point cp = c.getLocationOnScreen();
                    System.out.println("Screen Position = " + cp.x + " " + cp.y);
                    System.out.println("Window bounds = " + f.getBounds());
                  }
                });
                p.add("Center", b);
            }

            public static void main(String args[]) {
              Test3 g = new Test3();
                g.pack();
                g.setVisible(true);
            }

        }

              mbronsonsunw Mike Bronson (Inactive)
              mbronsonsunw Mike Bronson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: