From 7d52fb7ecd7fc336673fe5fecd3a872eb5aae64b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 7 Mar 2013 15:21:49 -0600 Subject: [PATCH] Add a PNG Files filter and select it by default --- .../antlr/v4/runtime/tree/gui/TreeViewer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/gui/TreeViewer.java b/runtime/Java/src/org/antlr/v4/runtime/tree/gui/TreeViewer.java index 66a4fa038..0ecd49cb8 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/gui/TreeViewer.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/gui/TreeViewer.java @@ -369,6 +369,25 @@ public class TreeViewer extends JComponent { JFileChooser fileChooser = new JFileChooserConfirmOverwrite(); fileChooser.setCurrentDirectory(suggestedFile.getParentFile()); fileChooser.setSelectedFile(suggestedFile); + FileFilter pngFilter = new FileFilter() { + + @Override + public boolean accept(File pathname) { + if (pathname.isFile()) { + return pathname.getName().toLowerCase().endsWith(".png"); + } + + return true; + } + + @Override + public String getDescription() { + return "PNG Files (*.png)"; + } + }; + + fileChooser.addChoosableFileFilter(pngFilter); + fileChooser.setFileFilter(pngFilter); int returnValue = fileChooser.showSaveDialog(dialog); if (returnValue == JFileChooser.APPROVE_OPTION) {