import java.beans.*;
/*
- * The GUI-class representing the add-, delete-, copy- or movetrack popup dialogs.
+ * The GUI-class representing the popupdialogs in the Track menu.
*
* @author Björn Lanneskog
*/
public class MooDialog extends JDialog {
- private JLabel name, whichToEdit;
- private JTextField textField;
+ private JLabel labelA, labelB, labelC;
+ private JTextField textFieldA, textFieldB, textFieldC;
private JComboBox trackListA, trackListB;
private JButton okButton, cancelButton;
public static final int ADD_TRACK = 1,
DELETE_TRACK = 2,
COPY_TRACK = 3,
- MOVE_TRACK = 4;
+ MOVE_TRACK = 4,
+ JUMP = 5;
/*
- * Create the parts that the dialogs have in common.
+ * Constructor of the dialogs.
*/
public MooDialog(int type) {
- super(Moosique.getGUI(), "Add track", false);
+ super(Moosique.getGUI(), false);
Container pane = getContentPane();
pane.setLayout(null);
switch (type) {
case ADD_TRACK:
- // Create the content of the add dialog and put them in a container.
- 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);
- trackListA = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
- pane.add(trackListA);
- cancelButton = new JButton("Cancel");
- pane.add(cancelButton);
- okButton = new JButton("OK");
- pane.add(okButton);
+ makeAddDialog(pane, tracks);
- // Set the layout properties of the dialog.
- name.setBounds(50, 10, 100, 20);
- textField.setBounds(40, 35, 120, 20);
- whichToEdit.setBounds(50, 70, 100, 20);
- trackListA.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:
-
- // Create the contents of the delete dialog and put them in a container.
- whichToEdit = new JLabel("Delete track", JLabel.CENTER);
- pane.add(whichToEdit);
- trackListA = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
- pane.add(trackListA);
- cancelButton = new JButton("Cancel");
- pane.add(cancelButton);
- okButton = new JButton("OK");
- pane.add(okButton);
-
- // Set the layout properties of the dialog.
- whichToEdit.setBounds(50, 10, 100, 20);
- trackListA.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);
+ makeDelDialog(pane, tracks);
+
break;
-
+
case COPY_TRACK:
-
- // Create the content of the copy dialog and put them in a container.
- name = new JLabel("Track to copy", JLabel.CENTER);
- pane.add(name);
- trackListA = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
- pane.add(trackListA);
- whichToEdit = new JLabel("Insert after", JLabel.CENTER);
- pane.add(whichToEdit);
- trackListB = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
- pane.add(trackListB);
- cancelButton = new JButton("Cancel");
- pane.add(cancelButton);
- okButton = new JButton("OK");
- pane.add(okButton);
- // Set the layout properties of the dialog.
- name.setBounds(50, 10, 100, 20);
- trackListA.setBounds(40, 35, 120, 20);
- whichToEdit.setBounds(50, 70, 100, 20);
- trackListB.setBounds(40, 95, 120, 20);
- cancelButton.setBounds(10, 150, 80, 30);
- okButton.setBounds(120, 150, 60, 30);
+ makeCopyDialog(pane, tracks);
- 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:
- // Create the content of the move dialog and put them in a container.
- name = new JLabel("Track to move", JLabel.CENTER);
- pane.add(name);
- trackListA = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
- pane.add(trackListA);
- whichToEdit = new JLabel("Insert after", JLabel.CENTER);
- pane.add(whichToEdit);
- trackListB = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
- pane.add(trackListB);
- cancelButton = new JButton("Cancel");
- pane.add(cancelButton);
- okButton = new JButton("OK");
- pane.add(okButton);
+ makeMoveDialog(pane, tracks);
- // Set the layout properties of the dialog.
- name.setBounds(40, 10, 120, 20);
- trackListA.setBounds(40, 35, 120, 20);
- whichToEdit.setBounds(50, 70, 100, 20);
- trackListB.setBounds(40, 95, 120, 20);
- cancelButton.setBounds(10, 150, 80, 30);
- okButton.setBounds(120, 150, 60, 30);
+ break;
- setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
- (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
- setResizable(false);
- pack();
- setSize(200,220);
- setVisible(true);
+ case JUMP:
+
+ makeJumpDialog(pane);
+
break;
}
}
+ /*
+ * Builds the add track popupdialog
+ */
+ private void makeAddDialog(Container pane, Track[] tracks) {
+
+ setTitle("Add track");
+ labelA = new JLabel("Name of track", JLabel.CENTER);
+ pane.add(labelA);
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ labelB = new JLabel("Add after", JLabel.CENTER);
+ pane.add(labelB);
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(50, 10, 100, 20);
+ textFieldA.setBounds(40, 35, 120, 20);
+ labelB.setBounds(50, 70, 100, 20);
+ trackListA.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);
+ }
+
+ /*
+ * Builds the delete track popupdialog
+ */
+ private void makeDelDialog(Container pane, Track[] tracks) {
+
+ setTitle("Delete track");
+ labelB = new JLabel("Delete track", JLabel.CENTER);
+ pane.add(labelB);
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelB.setBounds(50, 10, 100, 20);
+ trackListA.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);
+ }
+
+ /*
+ * Builds the copy track popupdialog
+ */
+ private void makeCopyDialog(Container pane, Track[] tracks) {
+
+ setTitle("Copy Track");
+ labelA = new JLabel("Track to copy", JLabel.CENTER);
+ pane.add(labelA);
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ labelB = new JLabel("Insert after", JLabel.CENTER);
+ pane.add(labelB);
+ trackListB = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
+ pane.add(trackListB);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(50, 10, 100, 20);
+ trackListA.setBounds(40, 35, 120, 20);
+ labelB.setBounds(50, 70, 100, 20);
+ trackListB.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);
+ }
+
+ /*
+ * Builds the move track popupdialog
+ */
+ private void makeMoveDialog(Container pane, Track[] tracks) {
+
+ setTitle("Move track");
+ labelA = new JLabel("Track to move", JLabel.CENTER);
+ pane.add(labelA);
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ labelB = new JLabel("Insert after", JLabel.CENTER);
+ pane.add(labelB);
+ trackListB = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
+ pane.add(trackListB);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(40, 10, 120, 20);
+ trackListA.setBounds(40, 35, 120, 20);
+ labelB.setBounds(50, 70, 100, 20);
+ trackListB.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);
+ }
+
+ /*
+ * Builds the jump popupdialog
+ */
+ private void makeJumpDialog(Container pane) {
+
+ setTitle("Jump");
+ labelA = new JLabel("Msr", JLabel.CENTER);
+ pane.add(labelA);
+ labelB = new JLabel("Beat", JLabel.CENTER);
+ pane.add(labelB);
+ labelC = new JLabel("Tick", JLabel.CENTER);
+ pane.add(labelC);
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ textFieldB = new JTextField();
+ pane.add(textFieldB);
+ textFieldC = new JTextField();
+ pane.add(textFieldC);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(30, 25, 50, 20);
+ labelB.setBounds(105, 25, 50, 20);
+ labelC.setBounds(180, 25, 50, 20);
+ textFieldA.setBounds(30, 45, 50, 20);
+ textFieldB.setBounds(105, 45, 50, 20);
+ textFieldC.setBounds(180, 45, 50, 20);
+ cancelButton.setBounds(35, 90, 80, 30);
+ okButton.setBounds(155, 90, 60, 30);
+
+ setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+ (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+ setResizable(false);
+ pack();
+ setSize(260,175);
+ setVisible(true);
+ }
private MooNote note;
private JOptionPane optionPane;