English 中文(简体)
Java JTree 案卷再次当选时冻结
原标题:Java JTree freezing when file is re-selected

我有一只JTree,我把它作为树子。 如果我选择一个新档案,选择与已经选定的文件相同,那么树木冻结有某种原因。 它应当拆除含有树木的旧的JScrollPane,代之以新的树种,如果我选择一个不同的卷宗,则它会做罚款,但不是用同一个文档。 全球倡议的其余部分仍在运作,它只是冻结的树木。 相关法典:

if ("browse".equals(e.getActionCommand())) {
        returnVal = fc.showOpenDialog(DSAuto.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            filename = file.getAbsolutePath();
            l1.setText("Job Location: " + filename);
            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1.0;
            c.gridx = 0;
            c.gridy = 1;
            c.gridwidth = 10;
            c.gridheight = 9;
            c.ipady = 0;
            if (rm)
                pane.remove(ft1);
            else
                pane.remove(sp1);
            if (rm2) {
                pane.remove(l3);
                rm2 = false;
            }
            if (!(file.isDirectory() || file.isFile())) {
                l3 = new JLabel("404 File Not Found");
                pane.add(l3, c);
                rm2 = true;
            } else {
                ft1 = new FileTree(file);
                ft1.all = allB;
                pane.add(ft1, c);
                rm = true;
            }
        }

    }

如果需要,我也可以为FileTree类提供法典。

最佳回答

It should be removing the old frame and replacing it with a new one

You can t add/remove a JFrame from a JFrame so I don t know what that comment means.

不要去除/去掉部分? 如果你想更新现有的构成部分,那么模式就会改变。 也就是说:

tree.setModel(...);

或者如果你去除/去除部件,那么你需要使用:

panel.revalidate();
panel.repaint();
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签