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

Using GridBagConstraints.BELOW_BASELINE/ABOVE BASELINE throws NPE when no Baseline is set.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • client-libs
    • b48
    • sparc
    • solaris_10

      Setting "anchor" field in GridBagConstraints as GridBagConstraints.ABOVE_BASELINE for all components when the row does not have any Baseline set. A NullPointerException is thrown. this Exception is thrown or all the components that has been added into the layout with the same "anchor" type.

      The Javadoc points out that if the row does not have a baseline set then the components will be centered vertically (This is mentioned in the anchor Description)

      This is consistently happening in the solaris platform - need to test in other platforms

      Attached Two Sample codes to reproduce the bugs. (Written for 2 anchor types GridBagConstraints.ABOVE_BASELINE and GridBagConstraints.BELOW_BASELINE

      Exception StackTrace Given below

      bash-3.00$ java AlignAboveBaselineTest1
      Exception in thread "main" java.lang.NullPointerException
              at java.awt.GridBagLayoutInfo.hasBaseline(GridBagLayout.java:60)
              at java.awt.GridBagLayout.alignAboveBaseline(GridBagLayout.java:1872)
              at java.awt.GridBagLayout.AdjustForGravity(GridBagLayout.java:1665)
              at java.awt.GridBagLayout.adjustForGravity(GridBagLayout.java:1603)
              at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:2149)
              at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1980)
              at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:840)
              at java.awt.Container.layout(Container.java:1402)
              at java.awt.Container.doLayout(Container.java:1391)
              at java.awt.Container.validateTree(Container.java:1474)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validate(Container.java:1449)
              at java.awt.Window.pack(Window.java:532)
              at AlignAboveBaselineTest1.testAlignAboveBaseline1(AlignAboveBaselineTest1.java:52)
              at AlignAboveBaselineTest1.<init>(AlignAboveBaselineTest1.java:24)
              at AlignAboveBaselineTest1.main(AlignAboveBaselineTest1.java:57)
      Exception occurred during event dispatching:
      java.lang.NullPointerException
              at java.awt.GridBagLayoutInfo.hasBaseline(GridBagLayout.java:60)
              at java.awt.GridBagLayout.alignAboveBaseline(GridBagLayout.java:1872)
              at java.awt.GridBagLayout.AdjustForGravity(GridBagLayout.java:1665)
              at java.awt.GridBagLayout.adjustForGravity(GridBagLayout.java:1603)
              at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:2149)
              at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1980)
              at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:840)
              at java.awt.Container.layout(Container.java:1402)
              at java.awt.Container.doLayout(Container.java:1391)
              at java.awt.Container.validateTree(Container.java:1474)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validate(Container.java:1449)
              at java.awt.Window.dispatchEventImpl(Window.java:2010)
              at java.awt.Component.dispatchEvent(Component.java:4194)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:592)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:270)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:198)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:171)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:166)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:119)
      Exception occurred during event dispatching:
      java.lang.NullPointerException
              at java.awt.GridBagLayoutInfo.hasBaseline(GridBagLayout.java:60)
              at java.awt.GridBagLayout.alignAboveBaseline(GridBagLayout.java:1872)
              at java.awt.GridBagLayout.AdjustForGravity(GridBagLayout.java:1665)
              at java.awt.GridBagLayout.adjustForGravity(GridBagLayout.java:1603)
              at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:2149)
              at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1980)
              at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:840)
              at java.awt.Container.layout(Container.java:1402)
              at java.awt.Container.doLayout(Container.java:1391)
              at java.awt.Container.validateTree(Container.java:1474)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validateTree(Container.java:1481)
              at java.awt.Container.validate(Container.java:1449)
              at java.awt.Window.dispatchEventImpl(Window.java:2010)
              at java.awt.Component.dispatchEvent(Component.java:4194)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:592)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:270)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:198)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:171)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:166)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:119)

      ###@###.### 2005-07-01 11:57:31 GMT

            svioletsunw Scott Violet (Inactive)
            bmathewssunw Blessan Mathews (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: