]> ruin.nu Git - moosique.git/blob - MooDialog.java
fc9c2c0b19bd39ad7c23a4560e06cac0513dcd0a
[moosique.git] / MooDialog.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4 import javax.sound.midi.*;
5 import java.io.*;
6 import java.beans.*;
7
8 /**
9  * A generator class for the application's dialogs.
10  *
11  * @author Björn Lanneskog
12  */
13  
14 public class MooDialog extends JDialog {
15
16         private JLabel labelA, labelB, labelC, labelD, labelE, labelF, labelG, labelH;
17         private JTextField textFieldA, textFieldB, textFieldC, textFieldD, textFieldE,
18                            textFieldF, textFieldG, textFieldH, textFieldI, textFieldJ,
19                            textFieldK;
20         private JComboBox trackListA, trackListB; 
21         private JButton okButton, cancelButton;
22         public static final int ADD_TRACK = 1,
23                                 DELETE_TRACK = 2,
24                                 COPY_TRACK = 3,
25                                 MOVE_TRACK = 4,
26                                 SET_POSITION = 5,
27                                 MANUAL = 6,
28                                 INSERT_MEASURE = 7,
29                                 DELETE_MEASURE = 8,
30                                 SET_TEMPO = 9,
31                                 PREFERENCES = 10,
32                                 TRANSPOSE = 11,
33                                 SCALE_VELOCITY = 12, 
34                                 RECORD = 13;
35         
36         /**
37          * Constructor of the dialogs.
38          */
39          public MooDialog(int type) {
40                 super(Moosique.getGUI(), false);
41                         
42                 Container pane = getContentPane();
43                 pane.setLayout(null);
44                 
45                 Track[] tracks = Moosique.getSequence().getTracks();
46
47                 switch (type) {
48                         case ADD_TRACK:         makeAddDialog(pane, tracks); break;
49                         case DELETE_TRACK:      makeDelDialog(pane, tracks); break;
50                         case COPY_TRACK:        makeCopyDialog(pane, tracks); break;
51                         case MOVE_TRACK:        makeMoveDialog(pane, tracks); break;
52                         case SET_POSITION:      makeSetPositionDialog(pane); break;
53                         case MANUAL:            makeTextDialog(pane, "Manual.txt"); break;
54                         case INSERT_MEASURE:    makeInsertMeasureDialog(pane); break;
55                         case DELETE_MEASURE:    makeDeleteMeasureDialog(pane); break;
56                         case SET_TEMPO:         makeSetTempoDialog(pane); break;
57                         case PREFERENCES:       makePrefsDialog(pane); break;
58                         case TRANSPOSE:         makeTransposeDialog(pane, tracks); break;
59                         case SCALE_VELOCITY:    makeScaleVelocityDialog(pane, tracks); break;
60                 }
61          }
62         
63         /**
64          * Builds the add track popupdialog.
65          * @param pane          The container to put the dialog in.
66          * @param tracks        A array containing miditracks.
67          */
68         private void makeAddDialog(Container pane, Track[] tracks) {
69                 setTitle("Add track");
70                 // create the contents of the dialog and add to container
71                 labelA = new JLabel("Name of track", JLabel.CENTER);
72                 pane.add(labelA);
73                 // textfield for naming track
74                 textFieldA = new JTextField();  
75                 pane.add(textFieldA);
76                 labelB = new JLabel("Add after", JLabel.CENTER);
77                 pane.add(labelB);
78                 // list of where to add track
79                 trackListA = new JComboBox();
80                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
81                 pane.add(trackListA);
82                 // ok and cancel button
83                 cancelButton = new JButton("Cancel");
84                 pane.add(cancelButton);
85                 okButton = new JButton("OK");
86                 pane.add(okButton);
87                 // set layout prop
88                 labelA.setBounds(50, 10, 100, 20);
89                 textFieldA.setBounds(40, 35, 120, 20);
90                 labelB.setBounds(50, 70, 100, 20);
91                 trackListA.setBounds(40, 95, 120, 20);
92                 cancelButton.setBounds(10, 150, 80, 30);
93                 okButton.setBounds(120, 150, 60, 30);
94                 setResizable(false);
95                 pack();
96                 setSize(200,220);
97                 setLocationRelativeTo(Moosique.getGUI());
98                 setVisible(true);
99         }
100         
101         /**
102          * Builds the delete track popupdialog.
103          * @param pane          The container to put the dialog in.
104          * @param tracks        A array containing miditracks.
105          */
106         private void makeDelDialog(Container pane, Track[] tracks) {
107                 setTitle("Delete track");
108                 // create the contents of the dialog and add to container
109                 labelB = new JLabel("Delete track", JLabel.CENTER);
110                 pane.add(labelB);
111                 // list of what track to delete
112                 trackListA = new JComboBox();
113                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
114                 pane.add(trackListA);
115                 // ok and cancelbutton
116                 cancelButton = new JButton("Cancel");
117                 pane.add(cancelButton);
118                 okButton = new JButton("OK");
119                 pane.add(okButton);
120                 // set layout prop      
121                 labelB.setBounds(50, 10, 100, 20);
122                 trackListA.setBounds(40, 35, 120, 20);
123                 cancelButton.setBounds(10, 90, 80, 30);
124                 okButton.setBounds(120, 90, 60, 30);
125                 setResizable(false);
126                 pack();
127                 setSize(200,165);
128                 setLocationRelativeTo(Moosique.getGUI());
129                 setVisible(true);
130         }
131         
132         /**
133          * Builds the copy track popupdialog.
134          * @param pane          The container to put the dialog in.
135          * @param tracks        A array containing miditracks.
136          */
137         private void makeCopyDialog(Container pane, Track[] tracks) {
138                 setTitle("Copy Track");
139                 // create the contents of the dialog and add to container
140                 labelA = new JLabel("Track to copy", JLabel.CENTER);
141                 pane.add(labelA);
142                 // list of what track to copy
143                 trackListA = new JComboBox();
144                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
145                 pane.add(trackListA);
146                 labelB = new JLabel("Insert after", JLabel.CENTER);
147                 pane.add(labelB);
148                 // list of where to put copied track
149                 trackListB = new JComboBox();
150                 for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
151                 pane.add(trackListB);
152                 cancelButton = new JButton("Cancel");
153                 pane.add(cancelButton);
154                 okButton = new JButton("OK");
155                 pane.add(okButton);
156                 // set layout prop
157                 labelA.setBounds(50, 10, 100, 20);
158                 trackListA.setBounds(40, 35, 120, 20);
159                 labelB.setBounds(50, 70, 100, 20);
160                 trackListB.setBounds(40, 95, 120, 20);
161                 cancelButton.setBounds(10, 150, 80, 30);
162                 okButton.setBounds(120, 150, 60, 30);
163                 setResizable(false);
164                 pack();
165                 setSize(200,220);
166                 setLocationRelativeTo(Moosique.getGUI());
167                 setVisible(true);
168         }
169         
170         /**
171          * Builds the move track popupdialog
172          * @param pane          The container to put the dialog in.
173          * @param tracks        A array containing miditracks.
174          */
175         private void makeMoveDialog(Container pane, Track[] tracks) {
176                 setTitle("Move track");
177                 // create the contents of the dialog and add to container
178                 labelA = new JLabel("Track to move", JLabel.CENTER);
179                 pane.add(labelA);
180                 // list of track to move
181                 trackListA = new JComboBox();
182                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
183                 pane.add(trackListA);
184                 labelB = new JLabel("Insert after", JLabel.CENTER);
185                 pane.add(labelB);
186                 // list of where to put moved track
187                 trackListB = new JComboBox();
188                 for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
189                 pane.add(trackListB);
190                 // ok and cancelbuttons
191                 cancelButton = new JButton("Cancel");
192                 pane.add(cancelButton);
193                 okButton = new JButton("OK");
194                 pane.add(okButton);
195                 // set layoutprop
196                 labelA.setBounds(40, 10, 120, 20);
197                 trackListA.setBounds(40, 35, 120, 20);
198                 labelB.setBounds(50, 70, 100, 20);
199                 trackListB.setBounds(40, 95, 120, 20);
200                 cancelButton.setBounds(10, 150, 80, 30);
201                 okButton.setBounds(120, 150, 60, 30);
202                 setResizable(false);
203                 pack();
204                 setSize(200,220);
205                 setLocationRelativeTo(Moosique.getGUI());
206                 setVisible(true);
207         }
208         
209         /**
210          * Builds the set position dialog.
211          * @param pane          The container to put the dialog in.
212          * @param tracks        A array containing miditracks.
213          */
214         private void makeSetPositionDialog(Container pane) {
215                 
216                 setTitle("Set edit position");
217                 // create the contents of the dialog and add to container
218                 labelA = new JLabel("Measure", JLabel.CENTER);
219                 pane.add(labelA);
220                 labelB = new JLabel("Beat", JLabel.CENTER);
221                 pane.add(labelB);
222                 labelC = new JLabel("Tick", JLabel.CENTER);
223                 pane.add(labelC);
224                 textFieldA = new JTextField();
225                 pane.add(textFieldA);
226                 textFieldB = new JTextField();
227                 pane.add(textFieldB);
228                 textFieldC = new JTextField();
229                 pane.add(textFieldC);
230                 // ok and cancel buttons
231                 cancelButton = new JButton("Cancel");
232                 pane.add(cancelButton);
233                 okButton = new JButton("OK");
234                 pane.add(okButton);
235                 // set layoutprop
236                 labelA.setBounds(40, 25, 50, 20);
237                 labelB.setBounds(105, 25, 50, 20);
238                 labelC.setBounds(170, 25, 50, 20);
239                 textFieldA.setBounds(40, 45, 50, 20);
240                 textFieldB.setBounds(105, 45, 50, 20);
241                 textFieldC.setBounds(170, 45, 50, 20);
242                 cancelButton.setBounds(35, 90, 80, 30);
243                 okButton.setBounds(155, 90, 60, 30);
244                 setResizable(false);
245                 pack();
246                 setSize(260,165);
247                 setLocationRelativeTo(Moosique.getGUI());
248                 setVisible(true);
249         }
250         
251         /**
252          * Builds the insert measure popupdialog.
253          * @param pane          The container to put the dialog in.
254          */
255         private void makeInsertMeasureDialog(Container pane){
256                 setTitle("Insert Measure");
257                 // create the contents of the dialog and add to container
258                 labelA = new JLabel("Insert at:", JLabel.RIGHT);
259                 pane.add(labelA);
260                 labelB = new JLabel("Measure count:", JLabel.RIGHT);
261                 pane.add(labelB);
262                 textFieldA = new JTextField();
263                 pane.add(textFieldA);
264                 textFieldB = new JTextField();
265                 pane.add(textFieldB);
266                 // ok and cancelbutton
267                 cancelButton = new JButton("Cancel");
268                 pane.add(cancelButton);
269                 okButton = new JButton("OK");
270                 pane.add(okButton);
271                 // set layout prop
272                 labelA.setBounds(20, 20, 110 ,20);
273                 labelB.setBounds(20, 50, 110, 20);
274                 textFieldA.setBounds(140 ,20 , 40, 20);
275                 textFieldB.setBounds(140,50, 40, 20);
276                 cancelButton.setBounds(20 ,95 , 80, 30);
277                 okButton.setBounds(120, 95, 60, 30);
278                 setResizable(false);
279                 pack();
280                 setSize(210,175);
281                 setLocationRelativeTo(Moosique.getGUI());
282                 setVisible(true);
283         }
284         
285         /**
286          * Builds the delete measure popupdialog.
287          * @param pane          The container to put the dialog in.
288          */
289         private void makeDeleteMeasureDialog(Container pane) {
290                 setTitle("Delete Measure");
291                 // create the contents of the dialog and add to container
292                 labelA = new JLabel("Delete at:", JLabel.RIGHT);
293                 pane.add(labelA);
294                 labelB = new JLabel("Measure count:", JLabel.RIGHT);
295                 pane.add(labelB);
296                 textFieldA = new JTextField();
297                 pane.add(textFieldA);
298                 textFieldB = new JTextField();
299                 pane.add(textFieldB);
300                 // ok and cancelbutton
301                 cancelButton = new JButton("Cancel");
302                 pane.add(cancelButton);
303                 okButton = new JButton("OK");
304                 pane.add(okButton);
305                 // set layout prop
306                 labelA.setBounds(20, 20, 110 ,20);
307                 labelB.setBounds(20, 50, 110, 20);
308                 textFieldA.setBounds(140 ,20 , 40, 20);
309                 textFieldB.setBounds(140,50, 40, 20);
310                 cancelButton.setBounds(20 ,95 , 80, 30);
311                 okButton.setBounds(120, 95, 60, 30);
312                 setResizable(false);
313                 pack();
314                 setSize(210,175);
315                 setLocationRelativeTo(Moosique.getGUI());
316                 setVisible(true);
317         }
318         
319         /**
320          * Builds the set tempo dialog.
321          * @param pane          The container to put the dialog in.
322          */
323         private void makeSetTempoDialog(Container pane) {
324                 setTitle("Set tempo");
325                 // create contents of dialog and add to container
326                 // track edit-intervall labels
327                 labelA = new JLabel("Measure", JLabel.CENTER);
328                 pane.add(labelA);
329                 labelB = new JLabel("Beat", JLabel.CENTER);
330                 pane.add(labelB);
331                 labelC = new JLabel("Tick", JLabel.CENTER);
332                 pane.add(labelC);
333                 // start and end labels
334                 labelD = new JLabel("Start at:", JLabel.RIGHT);
335                 pane.add(labelD);
336                 labelE = new JLabel("End at:", JLabel.RIGHT);
337                 pane.add(labelE);
338                 // from-to label
339                 labelF = new JLabel("to", JLabel.CENTER);
340                 pane.add(labelF);
341                 // start inputvaluefields
342                 textFieldA = new JTextField();
343                 pane.add(textFieldA);
344                 textFieldB = new JTextField();
345                 pane.add(textFieldB);
346                 textFieldC = new JTextField();
347                 pane.add(textFieldC);
348                 // end inputvaluefield
349                 textFieldD = new JTextField();
350                 pane.add(textFieldD);
351                 textFieldE = new JTextField();
352                 pane.add(textFieldE);
353                 textFieldF = new JTextField();
354                 pane.add(textFieldF);
355                 // the radiobuttonlists inputvaluefields
356                 textFieldG = new JTextField();
357                 pane.add(textFieldG);
358                 textFieldH = new JTextField();
359                 pane.add(textFieldH);
360                 textFieldI = new JTextField();
361                 pane.add(textFieldI);
362                 textFieldJ = new JTextField();
363                 pane.add(textFieldJ);
364                 textFieldK = new JTextField();
365                 pane.add(textFieldK);
366                 // the radiobuttonlist with associating titles
367                 JRadioButton constant = new JRadioButton("Set constant tempo of:");
368                 constant.setSelected(true);
369                 pane.add(constant);
370                 JRadioButton change = new JRadioButton("Gradually change tempo:");
371                 pane.add(change);
372                 JRadioButton scale = new JRadioButton("Scale tempo in %:");
373                 pane.add(scale);
374                 JRadioButton add = new JRadioButton("Add to current tempo:");
375                 pane.add(add);
376                 // a buttongroup for the radiobuttons
377                 ButtonGroup group = new ButtonGroup();
378                 group.add(constant);
379                 group.add(change);
380                 group.add(scale);
381                 group.add(add);
382                 // ok and cancelbutton
383                 cancelButton = new JButton("Cancel");
384                 pane.add(cancelButton);
385                 okButton = new JButton("OK");
386                 pane.add(okButton);
387                 
388                 // set bounds of track edit-intervall labels
389                 labelA.setBounds(80, 25, 50, 20);
390                 labelB.setBounds(145, 25, 50, 20);
391                 labelC.setBounds(210, 25, 50, 20);
392                 // set bounds of start and end labels
393                 labelD.setBounds(20, 45, 60, 20);
394                 labelE.setBounds(20, 65, 60, 20);
395                 // set bounds of from-to label
396                 labelF.setBounds(255, 125, 20 ,20);
397                 // set bounds of start inputvaluefields
398                 textFieldA.setBounds(80, 45, 50, 20);
399                 textFieldB.setBounds(145, 45, 50, 20);
400                 textFieldC.setBounds(210, 45, 50, 20);
401                 // set bounds of end inputvaluefield
402                 textFieldD.setBounds(80, 65, 50, 20);
403                 textFieldE.setBounds(145, 65, 50, 20);
404                 textFieldF.setBounds(210, 65, 50, 20);
405                 // set bounds of radiobuttonlists inputvaluefields
406                 textFieldG.setBounds(220, 100, 35, 20);
407                 textFieldH.setBounds(220, 125, 35, 20);
408                 textFieldI.setBounds(280, 125, 35, 20);
409                 textFieldJ.setBounds(220, 150, 35, 20);
410                 textFieldK.setBounds(220, 175, 35, 20);
411                 // set bounds of radiobuttonlist items
412                 constant.setBounds(20, 100, 180, 20);
413                 change.setBounds(20, 125, 200, 20);
414                 scale.setBounds(20, 150, 150, 20);
415                 add.setBounds(20, 175, 175, 20);
416                 // set bounds of ok and cancelbutton
417                 cancelButton.setBounds(75, 215, 80, 30);
418                 okButton.setBounds(195, 215, 60, 30);
419                 // set layout prop
420                 setResizable(false);
421                 pack();
422                 setSize(340,300);
423                 setLocationRelativeTo(Moosique.getGUI());
424                 setVisible(true);
425         }
426         
427         /**
428          * Builds the transpose dialog.
429          * @param pane          The container to put the dialog in.
430          * @param tracks        A array containing miditracks.
431          */
432         private void makeTransposeDialog(Container pane, Track[] tracks) {
433                 setTitle("Transpose");
434                 // create contents of dialog and add to container
435                 // track edit-intervall labels
436                 labelA = new JLabel("Measure", JLabel.CENTER);
437                 pane.add(labelA);
438                 labelB = new JLabel("Beat", JLabel.CENTER);
439                 pane.add(labelB);
440                 labelC = new JLabel("Tick", JLabel.CENTER);
441                 pane.add(labelC);
442                 // start and end labels
443                 labelD = new JLabel("Start at:", JLabel.RIGHT);
444                 pane.add(labelD);
445                 labelE = new JLabel("End at:", JLabel.RIGHT);
446                 pane.add(labelE);
447                 // oktave inputvalue labels
448                 labelF = new JLabel("Octaves", JLabel.LEFT);
449                 pane.add(labelF);
450                 labelG = new JLabel("1/2 octaves", JLabel.LEFT);
451                 pane.add(labelG);
452                 // what track to edit label
453                 labelH = new JLabel("Track to edit:", JLabel.CENTER);
454                 pane.add(labelH);
455                 // combobox representing the tracks
456                 trackListA = new JComboBox();
457                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
458                 pane.add(trackListA);
459                 // start inputvaluefields
460                 textFieldA = new JTextField();
461                 pane.add(textFieldA);
462                 textFieldB = new JTextField();
463                 pane.add(textFieldB);
464                 textFieldC = new JTextField();
465                 pane.add(textFieldC);
466                 // end inputvaluefield
467                 textFieldD = new JTextField();
468                 pane.add(textFieldD);
469                 textFieldE = new JTextField();
470                 pane.add(textFieldE);
471                 textFieldF = new JTextField();
472                 pane.add(textFieldF);
473                 // the radiobuttonlists inputvaluefields
474                 textFieldG = new JTextField();
475                 pane.add(textFieldG);
476                 textFieldH = new JTextField();
477                 pane.add(textFieldH);
478                 // the radiobuttonlist with associating titles
479                 JRadioButton up = new JRadioButton("Change up");
480                 up.setSelected(true);
481                 pane.add(up);
482                 JRadioButton down = new JRadioButton("Change down");
483                 pane.add(down);
484                 // a buttongroup for the radiobuttons
485                 ButtonGroup group = new ButtonGroup();
486                 group.add(up);
487                 group.add(down);
488                 // ok and cancelbutton
489                 cancelButton = new JButton("Cancel");
490                 pane.add(cancelButton);
491                 okButton = new JButton("OK");
492                 pane.add(okButton);
493                 
494                 // set bounds of track edit-intervall labels
495                 labelA.setBounds(90, 70, 50, 20);
496                 labelB.setBounds(155, 70, 50, 20);
497                 labelC.setBounds(220, 70, 50, 20);
498                 // set bounds of start and end labels
499                 labelD.setBounds(30, 90, 60, 20);
500                 labelE.setBounds(30, 110, 60, 20);
501                 // set bounds of octave inputvaluefields
502                 labelF.setBounds(210, 150, 80, 20);
503                 labelG.setBounds(210, 175, 100, 20);
504                 // set bounds of trackslist label
505                 labelH.setBounds(30, 30, 100, 20);
506                 // set bounds of start inputvaluefields
507                 textFieldA.setBounds(90, 90, 50, 20);
508                 textFieldB.setBounds(155, 90, 50, 20);
509                 textFieldC.setBounds(220, 90, 50, 20);
510                 // set bounds of end inputvaluefield
511                 textFieldD.setBounds(90, 110, 50, 20);
512                 textFieldE.setBounds(155, 110, 50, 20);
513                 textFieldF.setBounds(220, 110, 50, 20);
514                 // set bounds of octave inputvaluefields
515                 textFieldG.setBounds(170, 150, 35, 20);
516                 textFieldH.setBounds(170, 175, 35, 20);
517                 // set bounds of radiobuttonlist items
518                 up.setBounds(30, 150, 100, 20);
519                 down.setBounds(30, 175, 120, 20);
520                 // set bounds of tracklist
521                 trackListA.setBounds(145, 30, 120, 20);
522                 // set bounds of ok and cancelbutton
523                 cancelButton.setBounds(75, 215, 80, 30);
524                 okButton.setBounds(195, 215, 60, 30);
525                 // set layoutprop
526                 setResizable(false);
527                 pack();
528                 setSize(340,300);
529                 setLocationRelativeTo(Moosique.getGUI());
530                 setVisible(true);
531         }
532         
533         /**
534          * Builds the scale velocity dialog.
535          * @param pane  The container to put the dialog in.
536          * @param tracks        A array containing miditracks.
537          */
538         private void makeScaleVelocityDialog(Container pane, Track[] tracks) {
539                 setTitle("Scale velocity");
540                 // create contents of dialog and add to container
541                 // track edit-intervall labels
542                 labelA = new JLabel("Measure", JLabel.CENTER);
543                 pane.add(labelA);
544                 labelB = new JLabel("Beat", JLabel.CENTER);
545                 pane.add(labelB);
546                 labelC = new JLabel("Tick", JLabel.CENTER);
547                 pane.add(labelC);
548                 // start and end labels
549                 labelD = new JLabel("Start at:", JLabel.RIGHT);
550                 pane.add(labelD);
551                 labelE = new JLabel("End at:", JLabel.RIGHT);
552                 pane.add(labelE);
553                 // from-to label
554                 labelF = new JLabel("to", JLabel.CENTER);
555                 pane.add(labelF);
556                 // what track to edit label
557                 labelG = new JLabel("Track to edit:", JLabel.CENTER);
558                 pane.add(labelG);
559                 // combobox representing the tracks
560                 trackListA = new JComboBox();
561                 for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
562                 pane.add(trackListA);
563                 // start inputvaluefields
564                 textFieldA = new JTextField();
565                 pane.add(textFieldA);
566                 textFieldB = new JTextField();
567                 pane.add(textFieldB);
568                 textFieldC = new JTextField();
569                 pane.add(textFieldC);
570                 // end inputvaluefield
571                 textFieldD = new JTextField();
572                 pane.add(textFieldD);
573                 textFieldE = new JTextField();
574                 pane.add(textFieldE);
575                 textFieldF = new JTextField();
576                 pane.add(textFieldF);
577                 // the radiobuttonlists inputvaluefields
578                 textFieldG = new JTextField();
579                 pane.add(textFieldG);
580                 textFieldH = new JTextField();
581                 pane.add(textFieldH);
582                 textFieldI = new JTextField();
583                 pane.add(textFieldI);
584                 textFieldJ = new JTextField();
585                 pane.add(textFieldJ);
586                 textFieldK = new JTextField();
587                 pane.add(textFieldK);
588                 // the radiobuttonlist with associating titles
589                 JRadioButton constant = new JRadioButton("Change all values to:");
590                 constant.setSelected(true);
591                 pane.add(constant);
592                 JRadioButton change = new JRadioButton("Gradually  change value:");
593                 pane.add(change);
594                 JRadioButton scale = new JRadioButton("Scale values to %:");
595                 pane.add(scale);
596                 JRadioButton add = new JRadioButton("Add to current value:");
597                 pane.add(add);
598                 // a buttongroup for the radiobuttons
599                 ButtonGroup group = new ButtonGroup();
600                 group.add(constant);
601                 group.add(change);
602                 group.add(scale);
603                 group.add(add);
604                 // ok and cancelbutton
605                 cancelButton = new JButton("Cancel");
606                 pane.add(cancelButton);
607                 okButton = new JButton("OK");
608                 pane.add(okButton);
609                 
610                 // set bounds of track edit-intervall labels
611                 labelA.setBounds(80, 75, 50, 20);
612                 labelB.setBounds(145, 75, 50, 20);
613                 labelC.setBounds(210, 75, 50, 20);
614                 // set bounds of start and end labels
615                 labelD.setBounds(20, 95, 60, 20);
616                 labelE.setBounds(20, 115, 60, 20);
617                 // set bounds of from-to label
618                 labelF.setBounds(255, 175, 20 ,20);
619                 // set bounds of trackslist label
620                 labelG.setBounds(30, 30, 100, 20);
621                 // set bounds of start inputvaluefields
622                 textFieldA.setBounds(80, 95, 50, 20);
623                 textFieldB.setBounds(145, 95, 50, 20);
624                 textFieldC.setBounds(210, 95, 50, 20);
625                 // set bounds of end inputvaluefield
626                 textFieldD.setBounds(80, 115, 50, 20);
627                 textFieldE.setBounds(145,115, 50, 20);
628                 textFieldF.setBounds(210, 115, 50, 20);
629                 // set bounds of radiobuttonlists inputvaluefields
630                 textFieldG.setBounds(220, 150, 35, 20);
631                 textFieldH.setBounds(220, 175, 35, 20);
632                 textFieldI.setBounds(280, 175, 35, 20);
633                 textFieldJ.setBounds(220, 200, 35, 20);
634                 textFieldK.setBounds(220, 225, 35, 20);
635                 // set bounds of radiobuttonlist items
636                 constant.setBounds(20, 150, 180, 20);
637                 change.setBounds(20, 175, 200, 20);
638                 scale.setBounds(20, 200, 150, 20);
639                 add.setBounds(20, 225, 175, 20);
640                 // set bounds of tracklist
641                 trackListA.setBounds(145, 30, 120, 20);
642                 // set bounds of ok and cancelbutton
643                 cancelButton.setBounds(75, 265, 80, 30);
644                 okButton.setBounds(195, 265, 60, 30);
645                 // set layout prop
646                 setResizable(false);
647                 pack();
648                 setSize(340,350);
649                 setLocationRelativeTo(Moosique.getGUI());
650                 setVisible(true);
651         }
652         /** creates the "User manual dialog" that displays a  textfile
653         */
654         private void makeTextDialog(Container pane, String filename) {
655                 setTitle("User Manual");
656                 pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
657                 File manual = new File(filename);
658                 String s;
659                 try {
660                         BufferedReader br = new BufferedReader(new FileReader(manual));
661                         char[] chars = new char[(int)manual.length()];
662                         br.read(chars, 0, (int)manual.length());
663                         s = new String(chars);
664                 } catch (Exception ex) {
665                         s = "Manual not found";
666                 }
667                 JTextArea text = new JTextArea(s, 30, 95);
668                 text.setLineWrap(true);
669                 text.setWrapStyleWord(true);
670                 text.setEnabled(false);
671                 text.setDisabledTextColor(Color.black);
672                 pane.add(new JScrollPane(text));
673                 Action close = new AbstractAction("Close") {
674                         public void actionPerformed(ActionEvent ae) {
675                                 setVisible(false);
676                         }};
677                 JButton closeButton = new JButton(close);
678                 closeButton.setAlignmentX(Component.CENTER_ALIGNMENT);
679                 pane.add(closeButton);
680                 setResizable(false);
681                 pack();
682                 setLocationRelativeTo(Moosique.getGUI());
683                 setVisible(true);
684         }
685
686         private void makePrefsDialog(Container pane) {
687                 /*              
688                 MidiDevice.Info[] devInfo = MidiSystem.getMidiDeviceInfo();
689                 for (int i = 0; i < devInfo.length; i++) {
690                         if (MidiSystem.getMidiDevice(devInfo[i]) instanceof Sequencer) {
691                         
692                         } else if (MidiSystem.getMidiDevice(devInfo[i]) instanceof Synthesizer) {
693                         
694                         }
695                 }
696                 String[] seqNames, synthNames;
697                 JPanel pane = (JPanel) this.getContentPane();
698                 pane.add(new JLabel("Sequencer"));
699                 JComboBox seqBox = new JComboBox(seqNames);
700                 pane.add(new JLabel("Synthesizer"));
701                 JComboBox synthBox = new JComboBox(synthNames);
702                 */
703         }
704
705         private void makeRecordDialog(Container pane) {
706         /*      Show a dialog with:
707                 "Track" combo box,
708                 "Channel" field? (disabled?,
709                 "Quantize" pane with
710                         "Quantize" checkbox,
711                         "Resolution" combo box,
712                         "Location" checkboxes and
713                         "Duration" checkboxes
714                 "Start Recording" button.
715                 
716                 Moosique.record(track);
717                 */
718         }
719
720         private MooNote note;
721         private JOptionPane optionPane;
722         private JTextField pitch;
723         private JTextField velocity;
724         private JTextField length;
725         
726         /** 
727          * Creates a new note preference dialog.
728          * @param mn    the note that will be graphically represented
729          */
730         public MooDialog(MooNote mn) {
731                 super(Moosique.getGUI(), "Note properties", true);
732                 JPanel panel = new JPanel();
733                 panel.setLayout(new GridLayout(3,2));
734                 note = mn;
735                 pitch = new JTextField(new Integer(note.getPitch()).toString(),3);
736                 panel.add(new Label("Pitch: "));
737                 panel.add(pitch);
738
739                 velocity = new JTextField(new Integer(note.getVelocity()).toString(),3);
740                 panel.add(new Label("Velocity: "));
741                 panel.add(velocity);
742
743                 length = new JTextField(new Integer(note.getDuration()).toString(),5);
744                 panel.add(new Label("Length: "));
745                 panel.add(length);
746
747                 Object[] array = {"Set the note properties",
748                                 panel};
749         
750                 final String btnString1 = "Apply changes";
751                 final String btnString2 = "Cancel";
752                 Object[] options = {btnString1, btnString2};
753         
754                 optionPane = new JOptionPane(array, 
755                                             JOptionPane.QUESTION_MESSAGE,
756                                             JOptionPane.YES_NO_OPTION,
757                                             null,
758                                             options,
759                                             options[0]);
760                 setContentPane(optionPane);
761                 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
762         
763                 ActionListener intValidator = new ActionListener() {
764                     public void actionPerformed(ActionEvent e) {
765                                         if (e.getSource() instanceof JTextField){
766                                                 JTextField s = (JTextField)e.getSource();
767                                                 int num = Integer.parseInt(s.getText());
768                                                 if (num < 0)
769                                                         num = 0;
770                                                 else if (num > 127 && s != length)
771                                                         num = 127;
772                                                 s.setText(new Integer(num).toString());
773                                         }
774                     }
775                 };
776                 pitch.addActionListener(intValidator);
777                 velocity.addActionListener(intValidator);
778                 length.addActionListener(intValidator);
779
780                 optionPane.addPropertyChangeListener(new PropertyChangeListener() {
781                     public void propertyChange(PropertyChangeEvent e) {
782                         String prop = e.getPropertyName();
783         
784                         if (isVisible() 
785                          && (e.getSource() == optionPane)
786                          && (prop.equals(JOptionPane.VALUE_PROPERTY) ||
787                              prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
788                             Object value = optionPane.getValue();
789         
790                             if (value == JOptionPane.UNINITIALIZED_VALUE) {
791                                 //ignore reset
792                                 return;
793                             }
794         
795                             // Reset the JOptionPane's value.
796                             // If you don't do this, then if the user
797                             // presses the same button next time, no
798                             // property change event will be fired.
799                             optionPane.setValue(
800                                     JOptionPane.UNINITIALIZED_VALUE);
801         
802                             if (value.equals(btnString1)) {
803                                                         note.setPitch(Integer.parseInt(pitch.getText()));
804                                                         note.setVelocity(Integer.parseInt(velocity.getText()));
805                                                         note.setDuration(Integer.parseInt(length.getText()));
806                                                         Moosique.setEdited();
807                                                         setVisible(false);
808                             } else { // user closed dialog or clicked cancel
809                                 setVisible(false);
810                             }
811                         }
812                     }
813                 });
814                 pack();
815                 setVisible(true);
816         }
817 }