]> ruin.nu Git - moosique.git/blobdiff - MooMenu.java
varså god einar
[moosique.git] / MooMenu.java
index ca367b30cde88a4cdae3484f3a71c719c7d5859a..eeb1b218ce4f8ac4c18ddc420e9b60bc8415bbcf 100644 (file)
@@ -3,6 +3,11 @@ import javax.swing.filechooser.*;
 import java.awt.event.*;
 import java.io.*;
 
+/**
+ * Moosiques GUI representing a menubar, menus and menuitems
+ *
+ * @author Björn Lanneskog
+ */
 public class MooMenu extends JMenuBar implements ActionListener {
        
 /*
@@ -30,9 +35,11 @@ Music                Insert Measure...       Lagt till
 Kanske också:  Reset Solo / Mute
 
 */
-
        private JMenu file, edit, playback, track, help, music;
 
+       /**
+        * contructs a menubar
+        */
        public MooMenu() {
                file = makeMenu("File", KeyEvent.VK_F);
                add(file);
@@ -87,19 +94,38 @@ Kanske ocks
                help.add(makeItem(help, "About"));
        }
 
+       /**
+        * creates a menu for the menubar
+        * @param name          the name of the menu
+        * @param mnemonic      the shortcut to activate the menu
+        * @return menu         the menu to be added to the menubar
+        */
        private JMenu makeMenu(String name, int mnemonic) {
                JMenu menu = new JMenu(name);
                menu.setMnemonic(mnemonic);
                return menu;
        }
-
+       
+       /**
+        * creates a menuitem
+        * @param menu          the menu to which the item is being added to
+        * @param name          the name of this menuitem
+        * @return item         the item to add to the menu
+        */
        private JMenuItem makeItem(JMenu menu, String name) {
                JMenuItem item = new JMenuItem(name);
                item.addActionListener(this);
                menu.add(item);
                return item;
        }
-
+       
+       /**
+        * creates a menuitem
+        * @param menu          the menu to which the item is being added to
+        * @param name          the name of this menuitem
+        * @param key           the shortcut to activate the command
+        * @return item         the item to add to the menu
+        */
        private JMenuItem makeItem(JMenu menu, String name, int key) {
                JMenuItem item = new JMenuItem(name);
                item.setAccelerator(KeyStroke.getKeyStroke(key, ActionEvent.CTRL_MASK));
@@ -108,6 +134,11 @@ Kanske ocks
                return item;
        }
        
+       /**
+        * checks if the fileformat is compatible with our program
+        * @param f     the file to check
+        * @return true or false
+        */
        private boolean isMidiFile(File f) {
                if(f != null) {
                        String extension = f.getName().substring(f.getName().lastIndexOf('.') + 1).toLowerCase().trim();
@@ -152,10 +183,13 @@ Kanske ocks
                
                } else if (command == "Preferences") {
 
-               } else if (command == "Play") {
-                       Moosique.play();
+               } else if (command == "Play / Resume") {
+                       //if (Moosique.getSequence().isRunning()) {
+                               //Moosique.pause();
+                       //} else Moosique.play();
+               
                } else if (command == "Pause") {
-                       // Koda för resume också
+                       // koda för resume också
                        Moosique.pause();
                } else if (command == "Stop") {
                        Moosique.stop();
@@ -194,7 +228,7 @@ Kanske ocks
                        JOptionPane.showMessageDialog(null, "här kommer about att komma");
                }
        }
-
+       
        class MidiFileFilter extends javax.swing.filechooser.FileFilter {
                public boolean accept(File f) {
                        if(f != null) {
@@ -203,8 +237,12 @@ Kanske ocks
                        return false;
                }
                
+               /*
+                * gets the description of the filetype
+                * @return "Midifiles   the only filetyp compatibel with the program
+                */
                public String getDescription() {
                        return "MIDI files";
                }
        }
-}
\ No newline at end of file
+}