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

resizing dialogs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.1.7
    • 1.1.8
    • client-libs
    • None
    • b04
    • generic
    • windows_nt

        The test case shows a frame with a button (A).
        Push A and a modal dialog with button (B) is created.
        Resize the dialog and then push B to hide it.
        Push A again to reshow the dialog (should be packed back to original size).

        Push B again to hide and then A to reshow.

        In the jdk117fcs and jdk118L the dialog is usually resized correctly, but on second time, the button
        changes to the small square. 1.2 is the same as 118 except that the background of the dialog is not painted.

        (Using JDK116's the modal dialog (B) is usually left at the size the user resized to, as well as the button being a small square in the top left).


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

        public class Test {
          public static void main(String args[]) {
            final Frame f = new Frame("1");

            final Dialog d = new Dialog(f, "2", true);
            final Button b2 = new Button("B");
            b2.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                  d.setVisible(false);
               }
            });
                d.setLayout(new BorderLayout());
            d.add(b2, BorderLayout.CENTER);
                //d.setLayout(new GridLayout(1, 1));
            //d.add(b2);

            Button b = new Button("A");
            f.add(b, BorderLayout.CENTER);
            b.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                System.out.println("Button pref size " + b2.getPreferredSize());
                System.out.println("Dialog pref size " + d.getPreferredSize());
                d.pack();
                d.setVisible(true);
              }
            });
            f.pack();
            f.setVisible(true);
          }
        }

        The problem appears to be in the preferred size area. LayoutMgr.preferredLayoutSize calls
        Component.getPreferredSize which calls WComponentPeer.getPreferredSize which calls
        WComponentPeer.getMinimumSize.

        The sizes returned are around width=30/height=50 for the dialog, and width=22/height=23 for
        the button. The dialog's actual size is around 110 width (presumably this is the minimum
        windows size of 112) and does not go below this. However, the button can be sized to 22/23.
        Either the minimum size should be based on the minimum physical windows size, or the
        components should be size to the actual size of the container.


        adele.carrie@ireland 1999-04-01

              mmartaksunw Michael Martak (Inactive)
              acarrie Adele Carrie
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: