-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 03/06/2001
SwingUtilities.calculateInnerArea(JComponent c, Rectangle r) method throws
NullPointerException when passed JComponent is null. This behavior contradicts
with current javadoc which says:
----------------------------
public static Rectangle calculateInnerArea(JComponent c,
Rectangle r)
Stores the position and size of the inner painting area of the specified
component in r and returns r. The position and size specify the bounds
of the component, adjusted so as not to include the border area (the
insets). This method is useful for classes that implement painting code.
Parameters:
c - the JComponent in question; if null, this method returns null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
r - the Rectangle instance to be modified; may be null
----------------------------
This is a test example which shows this bug:
---------------------
import javax.swing.SwingUtilities;
import java.awt.Rectangle;
public class test {
public static void main(String[] args) {
Rectangle r = SwingUtilities.calculateInnerArea(null, new Rectangle());
}
}
---------------------
Test's output:
------------------------
Exception in thread "main" java.lang.NullPointerException
at
javax.swing.SwingUtilities.calculateInnerArea(SwingUtilities.java:1724)
at test.main(test.java:7)
-----------------------
It needs to be fixed.
======================================================================
- duplicates
-
JDK-4428238 The method SwingUtilities.calculateInnerArea works incorrectly
-
- Closed
-