如何在Jtree中刷新XML

我读了 here,但是如果xml文件发生了变化,jtree就不会重新加载/刷新
如何创建一个刷新/重新加载Jtree的函数
我尝试编写代码
refreshAction = new AbstractAction("Refresh",IconFactory.getIcon("delete",IconFactory.IconSize.SIZE_16X16)) {
public void actionPerformed(ActionEvent e) {
    XMLTree xmlClass = null;
    ((DefaultTreeModel) xmlClass.getModel()).reload(); 
    System.out.println("Refresh");
}};

但我得到了错误java.lang.NullPointerException

我在getJPopupForExplorerTree()中添加一个新的Action来弹出.你可能想要从XMLTree构造函数中重新考虑xmlFile;我在下面为了方便而硬编码:
popup.add(new AbstractAction("Reload") {

    public void actionPerformed(ActionEvent e) {
        System.out.println("Reload");
        try {
            root = getRoot("xml.xml");
            setModel(new XMLTreeModel(root));
        } catch (Exception ex) {
            ex.printstacktrace(System.err);
        }
    }
});

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念