+ setTitle("Set edit position");
+ labelA = new JLabel("Measure", 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);
+
+ setResizable(false);
+ pack();
+ setSize(260,165);
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+
+ /**
+ * Builds the insert measure popupdialog.
+ * @param pane The container to put the dialog in.
+ */
+ private void makeInsertMeasureDialog(Container pane){
+
+ setTitle("Insert Measure");
+ labelA = new JLabel("Insert at:", JLabel.RIGHT);
+ pane.add(labelA);
+ labelB = new JLabel("Measure count:", JLabel.RIGHT);
+ pane.add(labelB);
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ textFieldB = new JTextField();
+ pane.add(textFieldB);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(20, 20, 110 ,20);
+ labelB.setBounds(20, 50, 110, 20);
+ textFieldA.setBounds(140 ,20 , 40, 20);
+ textFieldB.setBounds(140,50, 40, 20);
+ cancelButton.setBounds(20 ,95 , 80, 30);
+ okButton.setBounds(120, 95, 60, 30);
+
+ setResizable(false);
+ pack();
+ setSize(210,175);
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+
+ /**
+ * Builds the delete measure popupdialog.
+ * @param pane The container to put the dialog in.
+ */
+ private void makeDeleteMeasureDialog(Container pane) {
+
+ setTitle("Delete Measure");
+ labelA = new JLabel("Delete at:", JLabel.RIGHT);
+ pane.add(labelA);
+ labelB = new JLabel("Measure count:", JLabel.RIGHT);
+ pane.add(labelB);
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ textFieldB = new JTextField();
+ pane.add(textFieldB);
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ labelA.setBounds(20, 20, 110 ,20);
+ labelB.setBounds(20, 50, 110, 20);
+ textFieldA.setBounds(140 ,20 , 40, 20);
+ textFieldB.setBounds(140,50, 40, 20);
+ cancelButton.setBounds(20 ,95 , 80, 30);
+ okButton.setBounds(120, 95, 60, 30);
+
+ setResizable(false);
+ pack();
+ setSize(210,175);
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+
+ private void makeTextDialog(Container pane, String filename) {
+ setTitle("User Manual");
+ pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
+ File manual = new File(filename);
+ String s;
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(manual));
+ char[] chars = new char[(int)manual.length()];
+ br.read(chars, 0, (int)manual.length());
+ s = new String(chars);
+ } catch (Exception ex) {
+ s = "Manual not found";
+ }
+ pane.add(new JScrollPane(new JTextArea(s, 30, 95)));
+ Action close = new AbstractAction("Close") {
+ public void actionPerformed(ActionEvent ae) {
+ setVisible(false);
+ }};
+ JButton closeButton = new JButton(close);
+ closeButton.setAlignmentX(Component.CENTER_ALIGNMENT);
+ pane.add(closeButton);
+ setResizable(false);
+ pack();
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+
+ private MooNote note;
+ private JOptionPane optionPane;
+ private JTextField pitch;
+ private JTextField velocity;
+ private JTextField length;
+
+ /**
+ * Creates a new note preference dialog.
+ * @param mn the note that will be graphically represented
+ */
+ public MooDialog(MooNote mn) {
+ super(Moosique.getGUI(), "Note properties", false);
+ note = mn;
+ pitch = new JTextField(new Integer(note.getPitch()).toString(),3);
+ JPanel pitchpanel = new JPanel();
+ pitchpanel.add(new Label("Pitch: "));
+ pitchpanel.add(pitch);
+
+ velocity = new JTextField(new Integer(note.getVelocity()).toString(),3);
+ JPanel velocitypanel = new JPanel();
+ velocitypanel.add(new Label("Velocity: "));
+ velocitypanel.add(velocity);
+
+ length = new JTextField(new Integer(note.getDuration()).toString(),5);
+ JPanel lengthpanel = new JPanel();
+ lengthpanel.add(new Label("Length: "));
+ lengthpanel.add(length);
+
+ Object[] array = {"Set the note properties",
+ pitchpanel,
+ velocitypanel,
+ lengthpanel};
+
+ final String btnString1 = "Apply changes";
+ final String btnString2 = "Cancel";
+ Object[] options = {btnString1, btnString2};
+
+ optionPane = new JOptionPane(array,
+ JOptionPane.QUESTION_MESSAGE,
+ JOptionPane.YES_NO_OPTION,
+ null,
+ options,
+ options[0]);
+ setContentPane(optionPane);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+
+ ActionListener intValidator = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() instanceof JTextField){
+ JTextField s = (JTextField)e.getSource();
+ int num = Integer.parseInt(s.getText());
+ if (num < 0)
+ num = 0;
+ else if (num > 127 && s != length)
+ num = 127;
+ s.setText(new Integer(num).toString());
+ }
+ }
+ };
+ pitch.addActionListener(intValidator);
+ velocity.addActionListener(intValidator);
+ length.addActionListener(intValidator);