Am Dienstag, den 05.12.2006, 11:31 +0100 schrieb Roman Kennke: > Am Dienstag, den 05.12.2006, 10:57 +0100 schrieb Mark Wielaard: > > On Tue, 2006-12-05 at 10:47 +0100, Roman Kennke wrote: > > > Am Montag, den 04.12.2006, 19:21 -0500 schrieb Thomas Fitzsimmons: > > > > This patch makes Component.getFont always return a non-null Font. This > > > > fixes a > > > > NullPointerException thrown by MegaMek. I committed this fix to trunk > > > > and > > > > classpath-0_93-branch. > > > > > > Hmm. While this makes the method more safe, I don't think that's 100% > > > correct. When a component has no parent or doesn't get a font from a > > > parent it indeed returns null. The WindowPeer seems to be responsible > > > for setting a font on the toplevel window AFAICS. > > > > It also fixed an issue for me with jedit (it makes the Plugins -> > > Plugins Options menu and dialog work for, so you can actually set the > > font for the QuickNotepad). If we cannot come up with something better I > > would like to ship with this patch. But it is not ideal, seeing that it > > did introduce mauve regressions for: > > > > FAIL: java.awt.Component.getFont > > FAIL: javax.swing.JComponent.getFont > > FAIL: javax.swing.JLabel.constructor > > FAIL: javax.swing.plaf.basic.BasicComboBoxUI.createRenderer > > FAIL: javax.swing.plaf.metal.MetalComboBoxUI.getMinimumSize > > FAIL: javax.swing.plaf.metal.MetalComboBoxUI.getPreferredSize > > > > It did also provide a new PASS however: > > > > PASS: > > javax.swing.table.JTableHeader.AccessibleJTableHeader.AccessibleJTableHeaderEntry.getFont > > Very strange. I'd say go for it for the release branch and let's really > fix it on HEAD.
Erm, another small nitpick. When we provide a default event for the case that no parent has a font etc, we shouldn't create a new font each time but instead return an instance that is stored in a static variable. getFont() can be called quite often and creating a new font on each call seems a little too expensive. /Roman
