1 year ago
#326750
lina
Restore all expanded node after file opening without collapsing whole tree
I am new to Java Swing and need your advice on the following issue to resolve the issue.
I'm trying to reset a specific node that was expanded before loading a new value in the tree table, the new values will be loaded without collapsing the whole tree.
The problem is that each time I open a file via open menu to load a new value in the tree table. Once I clicked the button "ok" in the open dialog, the new values are loaded but whole tree is automatically collapsed while executing the following line:
buttonOk.setText("OK");
buttonOk.addActionListener(evt -> buttonOkActionPerformed());
private void buttonOkActionPerformed() {// GEN-
FIRST:event_buttonOkActionPerformed
final OpenFiles selectedFiles = new OpenFiles(
new File(textParamDir.getText(), comboFile.getSelectedItem().toString());
switch (controller.performActionOpen(selectedFiles)) {
case OPEN_FAILED:
new JCBPOptionPane("Cannot Open. ", WARNING, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_OPTION, new String[] { "OK" });
controller.setControllerAfterDialog();
break;
case ERROR_INTERNAL:
new JCBPOptionPane("Internal Error", WARNING, JOptionPane.ERROR_MESSAGE, JOptionPane.OK_OPTION, new String[] { "OK" });
break;
case OPEN_SUCCESSFUL:
openMRPDialog.setVisible(false);
openMRPDialog.dispose();
break;
case ERROR_NOVALUES:
new JCBPOptionPane("No file chosen", WARNING, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_OPTION, new String[] { "OK" });
controller.setControllerAfterDialog();
break;
default:
}
}// GEN-LAST:event_buttonOkActionPerformed
Here, I need to keep a node as expanded that user expanded before opening the file to reload a value.
While debugging, the class EventDispatchThread lead to collapse the whole tree after loading a new value in the treetable.
Can anyone tell me how to refresh a node of a tree without collapsing the whole tree?
java
swing
jtree
0 Answers
Your Answer