Skip to content

Commit

Permalink
Fixed ..
Browse files Browse the repository at this point in the history
  • Loading branch information
DomAtTheShack committed Jun 5, 2023
1 parent 8eec046 commit b556327
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Binary file modified out/production/Dom-s-FTP-Client/FileBrowserGUI$1.class
Binary file not shown.
Binary file modified out/production/Dom-s-FTP-Client/FileBrowserGUI$2.class
Binary file not shown.
Binary file modified out/production/Dom-s-FTP-Client/FileBrowserGUI.class
Binary file not shown.
29 changes: 22 additions & 7 deletions src/FileBrowserGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ public FileBrowserGUI() {
fileList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == fileList && e.getClickCount() == 2) {
if (e.getClickCount() == 2) {
int selectedIndex = fileList.getSelectedIndex();
if (selectedIndex != -1) {
String selectedFile = listModel.getElementAt(selectedIndex);
File file = new File(currentDirectory, selectedFile);
if (file.isDirectory()) {
if (selectedFile.equals("..")) {
File parentDirectory = currentDirectory.getParentFile();
if (parentDirectory != null) {
navigateToDirectory(parentDirectory);
}
} else if (file.isDirectory()) {
navigateToDirectory(file);
}
}
Expand All @@ -137,24 +142,33 @@ public void valueChanged(ListSelectionEvent e) {
int selectedIndex = fileList.getSelectedIndex();
if (selectedIndex != -1) {
String selectedFile = listModel.getElementAt(selectedIndex);
File file = new File(currentDirectory, selectedFile);
selectedFileLabel.setText(file.getAbsolutePath());
selectedFileLabel.setText(currentDirectory.getAbsolutePath() + File.separator + selectedFile);
} else {
selectedFileLabel.setText("");
}
}
}
});




navigateToDirectory(new File(System.getProperty("user.home")));
selectedFileLabel.setText(currentDirectory.getPath());
setVisible(true);
}

private void navigateToDirectory(File directory) {
updateFileList(directory);
currentDirectory = directory;
selectedFileLabel.setText(currentDirectory.getAbsolutePath());
if (directory != null) {
updateFileList(directory);
currentDirectory = directory;

if (currentDirectory.getParentFile() != null) {
selectedFileLabel.setText(currentDirectory.getAbsolutePath());
} else {
selectedFileLabel.setText("");
}
}
}

private void updateFileList(File directory) {
Expand All @@ -174,6 +188,7 @@ private void updateFileList(File directory) {
}
}


public void setLoadingBar(int x) {
loadingBar.setValue(x);
}
Expand Down

0 comments on commit b556327

Please sign in to comment.