diff --git a/src/main/java/com/kfmanager/ui/FilePanel.java b/src/main/java/com/kfmanager/ui/FilePanel.java index 9795bc5..a4539e5 100644 --- a/src/main/java/com/kfmanager/ui/FilePanel.java +++ b/src/main/java/com/kfmanager/ui/FilePanel.java @@ -120,7 +120,17 @@ public class FilePanel extends JPanel { // Path field removed; path is shown in tab titles instead - // Button for parent directory + // Buttons for navigation + JPanel navBtnPaths = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0)); + JButton homeButton = new JButton("~"); + homeButton.setToolTipText("Home Directory"); + homeButton.addActionListener(e -> { + FilePanelTab currentTab = getCurrentTab(); + if (currentTab != null) { + currentTab.loadDirectory(new File(System.getProperty("user.home"))); + } + }); + JButton upButton = new JButton("↑"); upButton.setToolTipText("Parent directory (Backspace)"); upButton.addActionListener(e -> { @@ -129,7 +139,9 @@ public class FilePanel extends JPanel { currentTab.navigateUp(); } }); - topPanel.add(upButton, BorderLayout.EAST); + navBtnPaths.add(homeButton); + navBtnPaths.add(upButton); + topPanel.add(navBtnPaths, BorderLayout.EAST); add(topPanel, BorderLayout.NORTH); @@ -520,9 +532,10 @@ public class FilePanel extends JPanel { container.setBackground(bg); boolean dark = isDark(bg); for (Component c : container.getComponents()) { - if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JViewport || c instanceof JTabbedPane) { + if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JViewport || c instanceof JTabbedPane || c instanceof JButton) { c.setBackground(bg); - } else if (c instanceof JLabel || c instanceof JCheckBox || c instanceof JRadioButton) { + } + if (c instanceof JLabel || c instanceof JCheckBox || c instanceof JRadioButton || c instanceof JButton) { c.setForeground(dark ? Color.WHITE : Color.BLACK); } if (c instanceof Container) { diff --git a/src/main/java/com/kfmanager/ui/FilePanelTab.java b/src/main/java/com/kfmanager/ui/FilePanelTab.java index 2bc997c..97c1d2d 100644 --- a/src/main/java/com/kfmanager/ui/FilePanelTab.java +++ b/src/main/java/com/kfmanager/ui/FilePanelTab.java @@ -706,10 +706,14 @@ public class FilePanelTab extends JPanel { fileTable.setRowSelectionInterval(0, 0); fileTable.scrollRectToVisible(fileTable.getCellRect(0, 0, true)); } + fileTable.requestFocusInWindow(); }); } else { if (autoSelectFirst && fileTable.getRowCount() > 0) { fileTable.setRowSelectionInterval(0, 0); + SwingUtilities.invokeLater(() -> { + try { fileTable.requestFocusInWindow(); } catch (Exception ignore) {} + }); } } @@ -1002,24 +1006,11 @@ public class FilePanelTab extends JPanel { if (cur.equals(currentArchiveTempDir)) { File parent = currentArchiveSourceFile.getParentFile(); if (parent != null) { - String archiveName = currentArchiveSourceFile.getName(); // cleanup temp dir before switching back deleteTempDirRecursively(currentArchiveTempDir); currentArchiveTempDir = null; currentArchiveSourceFile = null; - loadDirectory(parent, false); - - if (viewMode == ViewMode.BRIEF) { - SwingUtilities.invokeLater(() -> { - tableModel.calculateBriefLayout(); - tableModel.fireTableStructureChanged(); - updateColumnRenderers(); - updateColumnWidths(); - selectItemByName(archiveName); - }); - } else { - selectItemByName(archiveName); - } + loadDirectory(parent, true); } return; } @@ -1028,20 +1019,7 @@ public class FilePanelTab extends JPanel { File parent = currentDirectory.getParentFile(); if (parent != null) { - String previousDirName = currentDirectory.getName(); - loadDirectory(parent, false); - - if (viewMode == ViewMode.BRIEF) { - SwingUtilities.invokeLater(() -> { - tableModel.calculateBriefLayout(); - tableModel.fireTableStructureChanged(); - updateColumnRenderers(); - updateColumnWidths(); - selectItemByName(previousDirName); - }); - } else { - selectItemByName(previousDirName); - } + loadDirectory(parent, true); } }