-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.2_02, 6
-
generic
-
generic
The method JComponent.paintImmediately() includes the following lines of code:
4614 try {
4615 try {
4616 Graphics pcg = paintingComponent.getGraphics();
4617 g = SwingGraphics.createSwingGraphics(pcg);
4618 pcg.dispose();
4619 } catch(NullPointerException e) {
4620 g = null;
4621 e.printStackTrace();
4622 }
When a GUI interaction in the application code causes a NPE, the stack trace is printed to the user, but the application code is not given the opportunity to react to the exception - the application code is not aware of the exception since it is caught in JComponent. In addition, the application does not have the option to turn off the printing of the stack trace to the user.
If you could remove the catching of the NPE (or perhaps re-throw the exception), the application would have the opportunity to handle the exception, if desired, and otherwise would simply print the stack trace as it does now.
4614 try {
4615 try {
4616 Graphics pcg = paintingComponent.getGraphics();
4617 g = SwingGraphics.createSwingGraphics(pcg);
4618 pcg.dispose();
4619 } catch(NullPointerException e) {
4620 g = null;
4621 e.printStackTrace();
4622 }
When a GUI interaction in the application code causes a NPE, the stack trace is printed to the user, but the application code is not given the opportunity to react to the exception - the application code is not aware of the exception since it is caught in JComponent. In addition, the application does not have the option to turn off the printing of the stack trace to the user.
If you could remove the catching of the NPE (or perhaps re-throw the exception), the application would have the opportunity to handle the exception, if desired, and otherwise would simply print the stack trace as it does now.
- duplicates
-
JDK-5081338 JComponent painting cleanup
- Resolved