import javax.swing.filechooser.*;
import java.awt.event.*;
import java.io.*;
+import java.awt.*;
/**
* Moosiques GUI representing a menubar, menus and menuitems
public class MooMenu extends JMenuBar implements ActionListener {
private JMenu file, edit, playback, music, help;
+ private JFileChooser chooser;
+ private File directory;
/**
* Creates the menu bar.
return item;
}
+ /**
+ * 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
if(command == "New") {
Moosique.clearSequence();
} else if (command == "Open...") {
- JFileChooser chooser = new JFileChooser();
+ // Shows a file chooser. If shown previously, starts in the current directory.
+ if (directory != null) {
+ chooser = new JFileChooser(directory);
+ } else {
+ chooser = new JFileChooser();
+ }
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...") {
- JFileChooser chooser = new JFileChooser();
+ // Shows a file chooser. If shown previously, starts in the current directory.
+ if (directory != null) {
+ chooser = new JFileChooser(directory);
+ } else {
+ chooser = new JFileChooser();
+ }
chooser.addChoosableFileFilter(new MidiFileFilter());
int returnVal = chooser.showSaveDialog(this);
- if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) {
- 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();
} else if (command == "Jump...") {
} else if (command == "Add track...") {
+
+ MooDialog what = new MooDialog(MooDialog.ADD_TRACK);
+
Moosique.getSequence().createTrack();
+
} else if (command == "Delete track...") {
+
+ MooDialog what = new MooDialog(MooDialog.DELETE_TRACK);
+
/* Let the user select a track from a list.
seq = Moosique.getSequence();
seq.deleteTrack(seq.getTracks()[NUMBER]);
*/
} else if (command == "Copy track...") {
+ MooDialog what = new MooDialog(MooDialog.COPY_TRACK);
+
} else if (command == "Move track...") {
+ MooDialog what = new MooDialog(MooDialog.MOVE_TRACK);
+
} else if (command == "Insert measure...") {
} else if (command == "Delete measure...") {
return "MIDI files";
}
}
-}
\ No newline at end of file
+
+
+}