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

pack() without show() does not make toplevels realized

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86, sparc
    • OS:
      linux, solaris_8

      Description



      Name: rpR10076 Date: 07/16/2001

      ###@###.###
      Judging by javadoc spec for pack() method it is natural to assume
      that after pack() the container (in our case, toplevels are of
      particular interest) is in the same state as after show()/hide().
      This is not exactly so on X11 platforms. After show()/hide() the
      toplevel container (and all of its children) is realized, but after
      just pack() it is not. The following code demostrates the problem
      (run with java_g):

      -----------------------------------------------------------------
      import java.awt.Frame;
      import java.awt.Image;
      import java.awt.Graphics;

      public class Test {
          public static void main(String argv[]) {
              Frame frame = new Frame("stuff");
              frame.pack();
              Graphics g = frame.getGraphics();
              g.drawImage(frame.createImage(10, 10), 0, 0, null);
          }
      }
      ------------------------------------------------------------------

      When drawImage(...) occurs, the frame (and the drawing area inside it)
      is not realized yet, which produces exception in debug mode. If after
      pack() you insert frame.show(); frame.hide(); and some delay to let
      those calls be finished properly, no exception happens.
      This issue came up while working on 4423128. It happens on Solaris,
      doesn't happen on win32, didn't test Linux but suspect it should
      happen there, too.

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vbaranovsunw Vyacheslav Baranov (Inactive)
                Reporter:
                prssunw Prs Prs (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: