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 {
/*
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);
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));
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();
} 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();
JOptionPane.showMessageDialog(null, "här kommer about att komma");
}
}
-
+
class MidiFileFilter extends javax.swing.filechooser.FileFilter {
public boolean accept(File f) {
if(f != null) {
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
+}