diff --git a/src/gui/GenericFileFilter.java b/src/gui/GenericFileFilter.java new file mode 100644 index 0000000..35d291c --- /dev/null +++ b/src/gui/GenericFileFilter.java @@ -0,0 +1,37 @@ +package gui; + +import java.io.File; +import java.io.FilenameFilter; + +import javax.swing.filechooser.FileFilter; + +class GenericFileFilter extends FileFilter implements FilenameFilter +{ + public String extension; + + public String getExtension() { + return extension; + } + + public GenericFileFilter(String extension) { + this.extension = extension.toLowerCase(); + } + + public String getDescription() + { + return extension; + } + + public boolean accept(File f, String name) + { + return (accept(f)); + } + + public boolean accept(File f) + { + if (f.isDirectory()) return true; + + return (f.getName().toLowerCase().endsWith(extension)); + } + +} diff --git a/src/gui/Main.java b/src/gui/Main.java index 080a755..6810422 100644 --- a/src/gui/Main.java +++ b/src/gui/Main.java @@ -2,6 +2,7 @@ package gui; import java.io.*; import java.util.HashSet; +import java.util.prefs.Preferences; import java.awt.EventQueue; import javax.swing.JFrame; @@ -10,7 +11,6 @@ import javax.swing.JOptionPane; import java.awt.GridBagLayout; import javax.swing.JLabel; -import java.awt.FileDialog; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.Rectangle; @@ -27,6 +27,7 @@ import java.awt.Color; import javax.swing.JScrollPane; import java.awt.FlowLayout; import javax.swing.JButton; +import javax.swing.JFileChooser; import javax.swing.JTable; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -34,6 +35,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; +import javax.swing.filechooser.FileFilter; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -49,23 +51,24 @@ import javax.swing.JMenuItem; public class Main implements ListSelectionListener, ActionListener, TableModelListener, LanguageModel { - private FileDialog openFileChooser = null; - private FileDialog saveFileChooser = null; - private JFrame frame; - private JTextArea lblInputFilename; - private JTextArea lblOutputFilename; - private JTextField tfFullName; - private JTable table; - private JButton buttonRemove; - private JButton buttonAdd; - private JButton buttonSave; - private JButton btnLanguage; - private JButton btnHeaderInfo; - private GuiModel model; - private File outputFile; - private boolean packHeader = false; - private JMenuItem mntmOpen; - private JMenuItem mntmSave; + private JFileChooser openFileChooser = null; + private JFileChooser saveFileChooser = null; + private Preferences prefs = null; + private JFrame frame; + private JTextArea lblInputFilename; + private JTextArea lblOutputFilename; + private JTextField tfFullName; + private JTable table; + private JButton buttonRemove; + private JButton buttonAdd; + private JButton buttonSave; + private JButton btnLanguage; + private JButton btnHeaderInfo; + private GuiModel model; + private File outputFile; + private boolean packHeader = false; + private JMenuItem mntmOpen; + private JMenuItem mntmSave; /** * Launch the application. @@ -75,7 +78,7 @@ public class Main implements ListSelectionListener, ActionListener, System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Mobi Meta Editor"); - + HashSet optionsSet = new HashSet(); File inputFile = null; for (int i=0; i