]> ruin.nu Git - moosique.git/blob - MooDialog.java
ee95f09eebb8a2c7fa6d95ece10275368f3ffb23
[moosique.git] / MooDialog.java
1 import javax.swing.*;
2 import java.awt.*;
3 import javax.sound.midi.*;
4
5 /*
6  * The add dialog that pops up if the user clicks on the add track menuitem
7  *
8  * @author Björn Lanneskog
9  */
10  
11 public class MooDialog extends JDialog {
12
13         private JLabel name, whichtoedit;
14         private JTextField textfield;
15         private JComboBox trackList, trackLust; 
16         private JButton okbutton, cancelbutton;
17         public static final int ADD_TRACK = 1, DELETE_TRACK = 2, COPY_TRACK = 3, MOVE_TRACK = 4;
18         
19         /*
20          * Creates the add dialog
21          */
22          public MooDialog(int type) {
23                 super(Moosique.getGUI(), "Add track", false);
24                         
25                 Container pane = getContentPane();
26                 pane.setLayout(null);
27
28                 Track[] tracks = Moosique.getSequence().getTracks();
29
30                 switch (type) {
31                         case ADD_TRACK:
32                                         
33                                 name = new JLabel("Name of track", JLabel.CENTER);
34                                 pane.add(name);
35                                 textfield = new JTextField();
36                                 pane.add(textfield);
37                                 whichtoedit = new JLabel("Add after", JLabel.CENTER);
38                                 pane.add(whichtoedit);
39                                 trackList = new JComboBox();
40                                 for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
41                                 pane.add(trackList);
42                                 cancelbutton = new JButton("Cancel");
43                                 pane.add(cancelbutton);
44                                 okbutton = new JButton("OK");
45                                 pane.add(okbutton);
46                                         
47                                 name.setBounds(50, 10, 100, 20);
48                                 textfield.setBounds(40, 35, 120, 20);
49                                 whichtoedit.setBounds(50, 70, 100, 20);
50                                 trackList.setBounds(40, 95, 120, 20);
51                                 cancelbutton.setBounds(10, 150, 80, 30);
52                                 okbutton.setBounds(120, 150, 60, 30);
53                         
54                                 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
55                                 (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
56                                 setResizable(false);
57                                 pack();
58                                 setSize(200,220);
59                                 setVisible(true);
60                                 break;
61                                 
62                         case DELETE_TRACK:
63                         
64                                 whichtoedit = new JLabel("Delete track", JLabel.CENTER);
65                                 pane.add(whichtoedit);
66                                 trackList = new JComboBox();
67                                 for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
68                                 pane.add(trackList);
69                                 cancelbutton = new JButton("Cancel");
70                                 pane.add(cancelbutton);
71                                 okbutton = new JButton("OK");
72                                 pane.add(okbutton);
73                                         
74                                 whichtoedit.setBounds(50, 10, 100, 20);
75                                 trackList.setBounds(40, 35, 120, 20);
76                                 cancelbutton.setBounds(10, 90, 80, 30);
77                                 okbutton.setBounds(120, 90, 60, 30);
78                         
79                                 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
80                                 (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
81                                 setResizable(false);
82                                 pack();
83                                 setSize(200,165);
84                                 setVisible(true);
85                                 break;
86                         
87                         case COPY_TRACK:
88                         
89                                 name = new JLabel("Track to copy", JLabel.CENTER);
90                                 pane.add(name);
91                                 trackLust = new JComboBox();
92                                 for (int i = 1; i <= tracks.length; i++) trackLust.addItem("Track " + i);
93                                 pane.add(trackLust);
94                                 whichtoedit = new JLabel("Insert after", JLabel.CENTER);
95                                 pane.add(whichtoedit);
96                                 trackList = new JComboBox();
97                                 for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
98                                 pane.add(trackList);
99                                 cancelbutton = new JButton("Cancel");
100                                 pane.add(cancelbutton);
101                                 okbutton = new JButton("OK");
102                                 pane.add(okbutton);
103                                         
104                                 name.setBounds(50, 10, 100, 20);
105                                 trackLust.setBounds(40, 35, 120, 20);
106                                 whichtoedit.setBounds(50, 70, 100, 20);
107                                 trackList.setBounds(40, 95, 120, 20);
108                                 cancelbutton.setBounds(10, 150, 80, 30);
109                                 okbutton.setBounds(120, 150, 60, 30);
110                         
111                                 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
112                                 (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
113                                 setResizable(false);
114                                 pack();
115                                 setSize(200,220);
116                                 setVisible(true);
117                                 break;
118                         
119                         case MOVE_TRACK:
120                                 
121                                 name = new JLabel("Track to move", JLabel.CENTER);
122                                 pane.add(name);
123                                 trackLust = new JComboBox();
124                                 for (int i = 1; i <= tracks.length; i++) trackLust.addItem("Track " + i);
125                                 pane.add(trackLust);
126                                 whichtoedit = new JLabel("Insert after", JLabel.CENTER);
127                                 pane.add(whichtoedit);
128                                 trackList = new JComboBox();
129                                 for (int i = 1; i <= tracks.length; i++) trackList.addItem("Track " + i);
130                                 pane.add(trackList);
131                                 cancelbutton = new JButton("Cancel");
132                                 pane.add(cancelbutton);
133                                 okbutton = new JButton("OK");
134                                 pane.add(okbutton);
135                                         
136                                 name.setBounds(40, 10, 120, 20);
137                                 trackLust.setBounds(40, 35, 120, 20);
138                                 whichtoedit.setBounds(50, 70, 100, 20);
139                                 trackList.setBounds(40, 95, 120, 20);
140                                 cancelbutton.setBounds(10, 150, 80, 30);
141                                 okbutton.setBounds(120, 150, 60, 30);
142                         
143                                 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
144                                 (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
145                                 setResizable(false);
146                                 pack();
147                                 setSize(200,220);
148                                 setVisible(true);
149                                 break;
150                 }
151                                 
152                 
153                 
154                 
155                          
156          }
157
158 }