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

componentResized not called when the form is snapped

XMLWordPrintable

        FULL PRODUCT VERSION :
        JDK 1.7.0 b134

        ADDITIONAL OS VERSION INFORMATION :
        Windows 7 Ultimate x86, fully patched

        A DESCRIPTION OF THE PROBLEM :
        The sample program produces strange drawing results when the frame is snapped vertically via the Windows 7 Aero's snap feature. The reason seems to be that when the snap occurs, the corresponding componentResized event never reaches the JFrame, therefore, the layout cannot accomodate the changes.

        The same program works with 1.6.0_24

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the program.
        Move it close to the top or bottom of the screen.
        Resize the window and accept the Windows 7 snap suggestion to make it vertically maximized.
        Observer the border mispaint and the lack of stdout report of a resize event

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The snapped size appears in the console, the border is painted full-window sized.
        ACTUAL -
        No resize event occurs.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class SnapBug extends JFrame {
        public SnapBug() {
        super("Snap bug");
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        JPanel p = new JPanel();
        p.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        p.setPreferredSize(new Dimension(640, 480));
        p.setBackground(Color.GREEN);
        getContentPane().add(p, BorderLayout.CENTER);
        addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
        System.out.printf("%d x %d%n", getWidth(), getHeight());
        }
        });
        pack();
        }
        public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        SnapBug b = new SnapBug();
        b.setVisible(true);
        }
        });
        }
        }

        ---------- END SOURCE ----------

              rupashka Pavel Porvatov (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: