Hi, The JFileChooser was giving NullPointerExceptions for me when resizing the window or when viewing a directory with few items. What happens is that the BasicDirectoryModel will give null as element after the end of list. The MetalFileChooserUI FileRenderer would try to get a name and icon for this "null" file which fails. This patch makes sure an empty name and no icon are rendered.
2005-01-12 Mark Wielaard <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalFileChooserUI.java
(FileRenderer.getListCellRendererComponent): Set empty name and null
icon when File is null.
Is this an acceptable way to fix this?
Cheers,
Mark
Index: javax/swing/plaf/metal/MetalFileChooserUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,v
retrieving revision 1.19
diff -u -r1.19 MetalFileChooserUI.java
--- javax/swing/plaf/metal/MetalFileChooserUI.java 5 Jan 2006 22:42:56 -0000 1.19
+++ javax/swing/plaf/metal/MetalFileChooserUI.java 12 Jan 2006 20:45:10 -0000
@@ -647,8 +647,16 @@
{
FileView v = getFileView(getFileChooser());
File f = (File) value;
- setText(v.getName(f));
- setIcon(v.getIcon(f));
+ if (f != null)
+ {
+ setText(v.getName(f));
+ setIcon(v.getIcon(f));
+ }
+ else
+ {
+ setText("");
+ setIcon(null);
+ }
setOpaque(true);
if (isSelected)
{
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
