}
/**
- * 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
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 {
}
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 {
}
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();
} 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();
*/
} 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...") {