]> ruin.nu Git - moosique.git/commitdiff
*** empty log message ***
authorBjörn Lanneskog <lannesko@itstud.chalmers.se>
Tue, 13 May 2003 16:58:14 +0000 (16:58 +0000)
committerBjörn Lanneskog <lannesko@itstud.chalmers.se>
Tue, 13 May 2003 16:58:14 +0000 (16:58 +0000)
MooDialog.java [new file with mode: 0644]
MooMenu.java

diff --git a/MooDialog.java b/MooDialog.java
new file mode 100644 (file)
index 0000000..ee95f09
--- /dev/null
@@ -0,0 +1,158 @@
+import javax.swing.*;
+import java.awt.*;
+import javax.sound.midi.*;
+
+/*
+ * The add dialog that pops up if the user clicks on the add track menuitem
+ *
+ * @author Björn Lanneskog
+ */
+public class MooDialog extends JDialog {
+
+       private JLabel name, whichtoedit;
+       private JTextField textfield;
+       private JComboBox trackList, trackLust; 
+       private JButton okbutton, cancelbutton;
+       public static final int ADD_TRACK = 1, DELETE_TRACK = 2, COPY_TRACK = 3, MOVE_TRACK = 4;
+       
+       /*
+        * Creates the add dialog
+        */
+        public MooDialog(int type) {
+               super(Moosique.getGUI(), "Add track", false);
+                       
+               Container pane = getContentPane();
+               pane.setLayout(null);
+
+               Track[] tracks = Moosique.getSequence().getTracks();
+
+               switch (type) {
+                       case ADD_TRACK:
+                                       
+                               name = new JLabel("Name of track", JLabel.CENTER);
+                               pane.add(name);
+                               textfield = new JTextField();
+                               pane.add(textfield);
+                               whichtoedit = new JLabel("Add after", JLabel.CENTER);
+                               pane.add(whichtoedit);
+                               trackList = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
+                               pane.add(trackList);
+                               cancelbutton = new JButton("Cancel");
+                               pane.add(cancelbutton);
+                               okbutton = new JButton("OK");
+                               pane.add(okbutton);
+                                       
+                               name.setBounds(50, 10, 100, 20);
+                               textfield.setBounds(40, 35, 120, 20);
+                               whichtoedit.setBounds(50, 70, 100, 20);
+                               trackList.setBounds(40, 95, 120, 20);
+                               cancelbutton.setBounds(10, 150, 80, 30);
+                               okbutton.setBounds(120, 150, 60, 30);
+                       
+                               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+                               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+                               setResizable(false);
+                               pack();
+                               setSize(200,220);
+                               setVisible(true);
+                               break;
+                               
+                       case DELETE_TRACK:
+                       
+                               whichtoedit = new JLabel("Delete track", JLabel.CENTER);
+                               pane.add(whichtoedit);
+                               trackList = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
+                               pane.add(trackList);
+                               cancelbutton = new JButton("Cancel");
+                               pane.add(cancelbutton);
+                               okbutton = new JButton("OK");
+                               pane.add(okbutton);
+                                       
+                               whichtoedit.setBounds(50, 10, 100, 20);
+                               trackList.setBounds(40, 35, 120, 20);
+                               cancelbutton.setBounds(10, 90, 80, 30);
+                               okbutton.setBounds(120, 90, 60, 30);
+                       
+                               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+                               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+                               setResizable(false);
+                               pack();
+                               setSize(200,165);
+                               setVisible(true);
+                               break;
+                       
+                       case COPY_TRACK:
+                       
+                               name = new JLabel("Track to copy", JLabel.CENTER);
+                               pane.add(name);
+                               trackLust = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackLust.addItem("Track " + i);
+                               pane.add(trackLust);
+                               whichtoedit = new JLabel("Insert after", JLabel.CENTER);
+                               pane.add(whichtoedit);
+                               trackList = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
+                               pane.add(trackList);
+                               cancelbutton = new JButton("Cancel");
+                               pane.add(cancelbutton);
+                               okbutton = new JButton("OK");
+                               pane.add(okbutton);
+                                       
+                               name.setBounds(50, 10, 100, 20);
+                               trackLust.setBounds(40, 35, 120, 20);
+                               whichtoedit.setBounds(50, 70, 100, 20);
+                               trackList.setBounds(40, 95, 120, 20);
+                               cancelbutton.setBounds(10, 150, 80, 30);
+                               okbutton.setBounds(120, 150, 60, 30);
+                       
+                               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+                               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+                               setResizable(false);
+                               pack();
+                               setSize(200,220);
+                               setVisible(true);
+                               break;
+                       
+                       case MOVE_TRACK:
+                               
+                               name = new JLabel("Track to move", JLabel.CENTER);
+                               pane.add(name);
+                               trackLust = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackLust.addItem("Track " + i);
+                               pane.add(trackLust);
+                               whichtoedit = new JLabel("Insert after", JLabel.CENTER);
+                               pane.add(whichtoedit);
+                               trackList = new JComboBox();
+                               for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
+                               pane.add(trackList);
+                               cancelbutton = new JButton("Cancel");
+                               pane.add(cancelbutton);
+                               okbutton = new JButton("OK");
+                               pane.add(okbutton);
+                                       
+                               name.setBounds(40, 10, 120, 20);
+                               trackLust.setBounds(40, 35, 120, 20);
+                               whichtoedit.setBounds(50, 70, 100, 20);
+                               trackList.setBounds(40, 95, 120, 20);
+                               cancelbutton.setBounds(10, 150, 80, 30);
+                               okbutton.setBounds(120, 150, 60, 30);
+                       
+                               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+                               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+                               setResizable(false);
+                               pack();
+                               setSize(200,220);
+                               setVisible(true);
+                               break;
+               }
+                               
+               
+               
+               
+                        
+        }
+
+}
index ab055a9a1959046e361f0f16b219b6596023070d..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
@@ -196,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();
@@ -238,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...") {