+ TreePath[] selectedPaths = fileTree.getSelectionPaths();
+ if ((selectedPaths != null) && (selectedPaths.length == 1)) {
+ Object lastPathComponent = selectedPaths[0].getLastPathComponent();
+ if (!(lastPathComponent instanceof SortableTreeNode)) {
+ logger.log(Level.WARNING, "lastPathComponent is not a SortableTreeNode!");
+ return;
+ }
+ SortableTreeNode node = (SortableTreeNode) lastPathComponent;
+ String completePath = getPathForNode(node);
+ int lastSeparator = completePath.lastIndexOf(File.separatorChar);
+ String filePath = "";
+ String fileName;
+ if (lastSeparator == -1) {
+ fileName = completePath;
+ } else {
+ filePath = completePath.substring(0, lastSeparator);
+ fileName = completePath.substring(lastSeparator + 1);
+ }
+ filePathTextField.setText(filePath);
+ fileNameTextField.setText(fileName);
+ return;
+ }
+ filePathTextField.setText("");
+ fileNameTextField.setText("");