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