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

Occasionally a frame is too big and the excess areas are drawn in black

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Backports

        Description

        JDK 1.1.5G seems to have a problem on Solaris which only shows up occasionally. When a new frame is created, it is initially invisible. This problem only shows up when when the frame is being made visible before setting it's size and location. It really only shows up sometimes so for a test it has to be tried several times. The effect is that sometimes the frame is too big and the excess areas are drawn in black. When this happens getBounds() returns wrong values after the frame has been moved or resized with the mouse. Sometimes (when the problem does not show up) it works just fine. I have not been able to reproduce this problem when the setSize() and setLocation() calls are made before the frame is being made visible. In this case getBounds() returns correct values.
        This problem does not show up in JDK1.1.4. However in 1.1.4 getBounds() almost always returns wrong values.

        Here is the testcase that I used:


        import java.awt.*;
        import java.awt.event.*;
        import java.util.*;
        import java.io.*;

        public class DisplayMgr extends Frame
        implements WindowListener, ComponentListener, ActionListener
        {
        Dimension windowSize = new Dimension(300,300);
        Point location = new Point(50,50);
        MenuBar mb;
        Menu file;
        MenuItem cause_bug_b;

        /////////////////////////////////////////////////////////////
        // Constructor
        public DisplayMgr()
        {
        super("TIM Graphics Display Manager");

        mb = new MenuBar();

        file = new Menu("File");

        // add menubar menues to the menubar
        mb.add(file);

        // menu items for the file menu
        cause_bug_b = new MenuItem("cause bug");
        // add file menuitems to file menu
        file.add(cause_bug_b);

        setMenuBar(mb); // add menubar to frame

        addComponentListener(this);
        addWindowListener(this);
        cause_bug_b.addActionListener(this);

        // Making the frame visible before setSize and setLocation()
        // are being called causes sometimes strange behaviour with
        // JDK1.1.5G. The frame is then sometimes to large and the
        // excess areas are drawn in black. This only happens
        // sometimes.
        setVisible(true);

        setSize(windowSize.width, windowSize.height);
        System.out.println("start() attempting to set location = " +
        location);
        setLocation(location.x, location.y);
        }

        /////////////////////////////////////////////////////////////
        // Window listeners
        public void windowClosing(WindowEvent e)
        {
        // user has double clicked the upper-right window mgr button
        System.exit(0);
        }
        public void windowOpened(WindowEvent e) {}
        public void windowClosed(WindowEvent e) {}
        public void windowIconified(WindowEvent e) {}
        public void windowDeiconified(WindowEvent e) {}
        public void windowActivated(WindowEvent e) {}
        public void windowDeactivated(WindowEvent e) {}

        /////////////////////////////////////////////////////////////
        // Component listeners
        public void componentResized(ComponentEvent e)
        {
        Rectangle bounds = getBounds();
        System.out.println("componentResized: bounds = " + bounds);
        }
        public void componentMoved(ComponentEvent e)
        {
        Rectangle bounds = getBounds();
        System.out.println("componentMoved: bounds = " + bounds);
        }
        public void componentShown(ComponentEvent e) {}
        public void componentHidden(ComponentEvent e) {}

        /////////////////////////////////////////////////////////////
        // Action listener
        public void actionPerformed(ActionEvent e)
        {
        setVisible(false);
        setVisible(true);
        return;
        }


        /////////////////////////////////////////////////////////////
        // Get the whole thing going -> main()
        public static void main(String args[])
        {
        new DisplayMgr();
        }
        }

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                pyoung Paul Young
                Reporter:
                rkarsunw Ralph Kar (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: