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

getBounds platform inconsistency on Windows and Linux

    XMLWordPrintable

Details

    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_07"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux hssd4.aoa.twosigma.com 2.6.14.2-ts8 #1 SMP PREEMPT Fri Apr 7 18:40:24 GMT 2006 x86_64 x86_64 x86_64 GNU/Linux

      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Using Exceed v10.0 to run the UI from Linux and display it on the Windows PC.

      A DESCRIPTION OF THE PROBLEM :
      When opening and closing a JFrame, the JFrame.getBounds() API returns inconsistent result on Linux and Windows.

      On Linux, getBounds returns width and height slightly larger than those when the window was opened (even if the window remains untouched between opening and closing). A log.debug was placed into WindowListener.windowOpened and windowClosing, here is the result:

      2006-08-24 16:26:17,239 DEBUG ui.view.AbstractGridViewForm Window tradingui.executionmode.view.ExecutionModeViewForm[frame0,0,0,715x279,layout=java.awt.BorderLayout,title=Execution Mode View,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,715x279,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true] opened

      2006-08-24 16:26:35,753 DEBUG ui.view.AbstractGridViewForm Window tradingui.executionmode.view.ExecutionModeViewForm[frame0,0,0,723x306,invalid,layout=java.awt.BorderLayout,title=Execution Mode View,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=javax.swing.JRootPane[,4,23,715x279,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true] closing

      As you can see, when this window was opened it's widthxheight were 715x279. However, when the window is closing the same bounds become 723x306. Interestingly enough the root pane maintains the bounds identical to those when the window was opened, 715x279.

      The behavior is different on Windows. Here JFrame.getBounds() returns the same result when the window is opened and when it is closed, however JFrame.getRoonPane().getBounds() returns slightly smaller width and height.

      This inconsistency makes it difficult to write code that saves window preferences on Linux and WIndows, because different ways (JFrame.getRootPane.getBounds vs Frame.getBounds) must be used depending on the OS.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      % javac JFrameGetBoundsBug.java
      % java JFrameGetBoundsBug 200 100

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The same values from getBounds on both platforms.
      ACTUAL -
      Different values on WIndows and Linux, as described earlier.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Attached seperately.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      If os.name == Linux use JFrame.getRootPane.getBounds, else use JFrame.getBounds

      Attachments

        Activity

          People

            anthony Anthony Petrov (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: