]> ruin.nu Git - moosique.git/blobdiff - MooMenu.java
removed some stuff
[moosique.git] / MooMenu.java
index 892e7658a93343943721748edf1af73a189d4303..8d1caeaa11ec4a2e5a5b8413841401b0b60c5f7d 100644 (file)
@@ -110,15 +110,13 @@ public class MooMenu extends JMenuBar implements ActionListener {
        }
        
        /**
-       * creates a JFrame popupmenu, containing diffrent choices
-       * @param title  the title of the JFrame
-       * @param labelone       the first label of two
-       * @param labeltwo       the second label of two
-       * @return trackframe    the JFrame to popup....ffaaaaaaaaaaaaaaaan!
+       * creates a JDialog popupmenu, containing diffrent choices
+       * @param title          the title of the dialog
+       * @return trackframe    the JDialog....ffaaaaaaaaaaaaaaaan!
        */
-       
-               
-       
+       //private JDialog makeDialog(String title){
+       //      
+       //}
        /**
         * checks if the fileformat is compatible with our program
         * @param f     the file to check
@@ -139,6 +137,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
                if(command == "New") {
                        Moosique.clearSequence();
                } else if (command == "Open...") {
+                       // Shows a file chooser. If shown previously, starts in the current directory.
                        if (directory != null) {
                                chooser = new JFileChooser(directory);
                        } else {
@@ -146,13 +145,17 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        }
                        chooser.addChoosableFileFilter(new MidiFileFilter());
                        int returnVal = chooser.showOpenDialog(this);
-                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) {
+
+                       // Stores the current directory and loads the selected file.
+                       File file = chooser.getSelectedFile();
+                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) {
                                directory = chooser.getSelectedFile().getParentFile();
                                Moosique.load(chooser.getSelectedFile().getAbsolutePath());
                        }
                } else if (command == "Save") {
                        Moosique.save();
                } else if (command == "Save as...") {
+                       // Shows a file chooser. If shown previously, starts in the current directory.
                        if (directory != null) {
                                chooser = new JFileChooser(directory);
                        } else {
@@ -160,9 +163,12 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        }
                        chooser.addChoosableFileFilter(new MidiFileFilter());
                        int returnVal = chooser.showSaveDialog(this);
-                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) {
-                               directory = chooser.getSelectedFile().getParentFile();
-                               Moosique.saveAs(chooser.getSelectedFile().getAbsolutePath());
+
+                       // Stores the current directory and loads the selected file.
+                       File file = chooser.getSelectedFile();
+                       if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) {
+                               directory = file.getParentFile();
+                               Moosique.saveAs(file.getAbsolutePath());
                        }
                } else if (command == "Exit") {
                        Moosique.quit();
@@ -188,41 +194,13 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        
                } else if (command == "Add track...") {
                
-                       JFrame frame = new JFrame("Add track");
-                       JPanel panel = new JPanel();
-                       //panel.setPreferredSize(new Dimension(250,400));
-                       panel.setLayout(new GridLayout(2,2));
-                       frame.setContentPane(panel);
-                       
-                       JLabel top = new JLabel("Name of track", JLabel.CENTER);
-                       top.setFont(new Font("Times new Roman", Font.BOLD, 10));
-                       panel.add(top);
-                       
-                       JTextField field = new JTextField(5);
-                       panel.add(field);
-                      
-                       JLabel bottom = new JLabel("Add it after",JLabel.CENTER);
-                       bottom.setFont(new Font("Times new Roman", Font.BOLD, 10));
-                       panel.add(bottom);
-                       
-                       JComboBox tracklist = new JComboBox();
-                       panel.add(tracklist);
-                       
-                       
-                       frame.pack();
-                       frame.show();
+                       MooDialog what = new MooDialog(MooDialog.ADD_TRACK);
                        
                        Moosique.getSequence().createTrack();
                        
                } else if (command == "Delete track...") {
-                       
-                       JFrame frame = new JFrame("Delete track");
-                       JPanel panel = new JPanel();
-                       panel.setPreferredSize(new Dimension(250,400));
-                       frame.setContentPane(panel);
-                       
-                       frame.pack();
-                       frame.show();
+               
+                       MooDialog what = new MooDialog(MooDialog.DELETE_TRACK);
                        
                        /* Let the user select a track from a list.
                        seq = Moosique.getSequence();
@@ -230,25 +208,11 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        */
                } else if (command == "Copy track...") {
                
-                       JFrame frame = new JFrame("Copy track");
-                       JPanel panel = new JPanel();
-                       panel.setPreferredSize(new Dimension(250,400));
-                       frame.setContentPane(panel);
+                       MooDialog what = new MooDialog(MooDialog.COPY_TRACK);
                        
-                       frame.pack();
-                       frame.show();
-               
                } else if (command == "Move track...") {
                
-                       JFrame frame = new JFrame("Move track");
-                       JPanel panel = new JPanel();
-                       panel.setPreferredSize(new Dimension(250,400));
-                       panel.setLayout(new GridLayout(2,2));
-                       frame.setContentPane(panel);
-                       
-                       frame.pack();
-                       frame.show();
-               
+                       MooDialog what = new MooDialog(MooDialog.MOVE_TRACK);
 
                } else if (command == "Insert measure...") {