User account creation filtered due to spam.

Bug 24077

Summary: Cannot create JFileChooser due to NPE (getFontMetrics)
Product: classpath Reporter: Norman Hendrich <hendrich>
Component: swingAssignee: Lillian Angel <langel>
Severity: normal CC: bug-classpath
Priority: P2    
Version: unspecified   
Target Milestone: 0.19   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-09-27 19:13:18

Description Norman Hendrich 2005-09-27 08:45:11 UTC
Swing is almost completely broken at the moment (due to changes introduced
by the recent repaint refactoring). There are NPEs all over the place.
Here is my favorite, stacktrace from jamvm 1.3.2 and Classpath CVS 2005.09.29 
on x86 linux:

jamvm niffler.JImageViewer ~/.niffler
   at<init> (
   at (
   at javax.swing.plaf.basic.BasicComboBoxRenderer.getListCellRendererComponent 
   at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize (BasicComboBoxUI.jav
   at javax.swing.plaf.basic.BasicComboBoxUI$ListDataHandler.intervalAdded (Basi
   at javax.swing.AbstractListModel.fireIntervalAdded (
   at javax.swing.DefaultComboBoxModel.addElement (
   at javax.swing.JComboBox.addItem (
   at javax.swing.plaf.basic.BasicFileChooserUI.boxEntries (BasicFileChooserUI.j
   at javax.swing.plaf.basic.BasicFileChooserUI.installComponents (BasicFileChoo
   at javax.swing.plaf.basic.BasicFileChooserUI.installUI (BasicFileChooserUI.ja
   at javax.swing.JComponent.setUI (
   at javax.swing.JFileChooser.updateUI (
   at javax.swing.JFileChooser.setup (
   at javax.swing.JFileChooser.<init> (
   at niffler.JImageViewer.checkCreateFileChooser (
Comment 1 Lillian Angel 2005-09-27 20:34:49 UTC
*** Bug 24078 has been marked as a duplicate of this bug. ***
Comment 2 Lillian Angel 2005-09-27 20:35:06 UTC
*** Bug 24081 has been marked as a duplicate of this bug. ***
Comment 3 Lillian Angel 2005-09-27 20:56:09 UTC
A UI delegate should install its default font on a JComponent only if the
existing font is null or implements UIResource.  

For some reason, many UI delegates are not setting the default font. It is
correct for Component.getFont to return null when no default font has been set.

I am looking into which UIs have not set their default fonts.
Comment 4 Lillian Angel 2005-09-28 13:56:16 UTC
Comment 5 2005-09-28 14:09:03 UTC
Subject: Bug 24077

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Changes by:	Lillian Angel <>	05/09/28 13:59:14

Modified files:
	.              : ChangeLog 
	javax/swing    : 

Log message:
	2005-09-28  Lillian Angel  <>
	Fixes Bug #24077
	* gnu/java/awt/peer/gtk/
	(GdkFontMetrics): Added a check for the font
	being null. Fixed a NPE.
	* gnu/java/awt/peer/gtk/
	(GdkGraphics): Added check if the font is null.
	If it is, the font should be set to the default.
	(setFont): If font parameter is null, this.font should not
	be changed.
	* javax/swing/
	Fixed API documentation to say 'JDialog' rather than