diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 6f8496b..67c353e 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -204,4 +204,6 @@ Others: ## 1.1 更新内容: +- [important] 选择文件时只显示JAR/WAR文件提高效率 #84 +- [bug] 应该支持隐藏文件/目录 #85 - [improve] 限制JAR包大小防止加载过多过大的文件 #83 \ No newline at end of file diff --git a/src/main/java/com/chaitin/jar/analyzer/form/JarAnalyzerForm.java b/src/main/java/com/chaitin/jar/analyzer/form/JarAnalyzerForm.java index 0628c52..fa72b82 100644 --- a/src/main/java/com/chaitin/jar/analyzer/form/JarAnalyzerForm.java +++ b/src/main/java/com/chaitin/jar/analyzer/form/JarAnalyzerForm.java @@ -29,6 +29,7 @@ import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileFilter; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.datatransfer.DataFlavor; @@ -237,6 +238,19 @@ public void loadJar() { selectJarFileButton.addActionListener(e -> { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setFileHidingEnabled(true); + fileChooser.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + return f.getName().toLowerCase().endsWith(".jar") || + f.getName().toLowerCase().endsWith(".war"); + } + + @Override + public String getDescription() { + return "NOT JAR/WAR"; + } + }); int option = fileChooser.showOpenDialog(new JFrame()); if (option == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile();