A
Abs
Hi!
I'm trying to get my swing app to work in both Windows and Linux. Right
now, it works in Windows, but in Linux (Mandrake) it returns a
ClassCastException in the getTreeCellRendererComponent() method in my
custom TreeCellRenderer. My app shows a filesystem tree.
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
String name=fsv.getSystemDisplayName(((FileNode)value).getFile());
// CLASSCASTEXCEPTION HERE
super.getTreeCellRendererComponent(tree, name, selected, expanded,
leaf, row, hasFocus);
setText(name);
setIcon(fsv.getSystemIcon(((FileNode)value).getFile()));
return this;
}
I don't know why the FileNode class cast throws a ClassCastException in
Linux but not in Windows. Here is the code for the FileNode class:
public class FileNode extends DefaultMutableTreeNode {
private FileSystemView fsv=FileSystemView.getFileSystemView();
public FileNode(String name) {
setUserObject(new File(name));
}
public FileNode(File file) {
setUserObject(file);
}
public boolean getAllowsChildren() {
return isDirectory();
}
public boolean isLeaf() {
return !isDirectory();
}
public File getFile() {
return (File)getUserObject();
}
public boolean isDirectory() {
File file = getFile();
return fsv.isTraversable(file).booleanValue();
}
}
Can anyone help me, please ? Is FileSystemView broken in Linux ? I'm
using 1.4.2 in both Windows (the full JSDK) and Linux (the JRE).
I'm trying to get my swing app to work in both Windows and Linux. Right
now, it works in Windows, but in Linux (Mandrake) it returns a
ClassCastException in the getTreeCellRendererComponent() method in my
custom TreeCellRenderer. My app shows a filesystem tree.
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
String name=fsv.getSystemDisplayName(((FileNode)value).getFile());
// CLASSCASTEXCEPTION HERE
super.getTreeCellRendererComponent(tree, name, selected, expanded,
leaf, row, hasFocus);
setText(name);
setIcon(fsv.getSystemIcon(((FileNode)value).getFile()));
return this;
}
I don't know why the FileNode class cast throws a ClassCastException in
Linux but not in Windows. Here is the code for the FileNode class:
public class FileNode extends DefaultMutableTreeNode {
private FileSystemView fsv=FileSystemView.getFileSystemView();
public FileNode(String name) {
setUserObject(new File(name));
}
public FileNode(File file) {
setUserObject(file);
}
public boolean getAllowsChildren() {
return isDirectory();
}
public boolean isLeaf() {
return !isDirectory();
}
public File getFile() {
return (File)getUserObject();
}
public boolean isDirectory() {
File file = getFile();
return fsv.isTraversable(file).booleanValue();
}
}
Can anyone help me, please ? Is FileSystemView broken in Linux ? I'm
using 1.4.2 in both Windows (the full JSDK) and Linux (the JRE).