X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooDialog.java;h=f78d24c711da9d9b02176b4f0fc73cd08163a0e6;hb=a8b0b5e27d120df964c5b6d8554a6207951b00d0;hp=d4530bd6f8ae437e66f77a3da04e7b4b0cd7ee96;hpb=abdd0789dfa2329312d8cdebc114728192935360;p=moosique.git diff --git a/MooDialog.java b/MooDialog.java index d4530bd..f78d24c 100644 --- a/MooDialog.java +++ b/MooDialog.java @@ -6,7 +6,7 @@ import java.io.*; import java.beans.*; /** - * The GUI-class representing the popupdialogs in the Track menu. + * A generator class for the application's dialogs. * * @author Björn Lanneskog */ @@ -21,8 +21,10 @@ public class MooDialog extends JDialog { DELETE_TRACK = 2, COPY_TRACK = 3, MOVE_TRACK = 4, - JUMP = 5, - CONTENTS = 6; + SET_POSITION = 5, + MANUAL = 6, + INSERT_MEASURE = 7, + DELETE_MEASURE = 8; /** * Constructor of the dialogs. @@ -40,13 +42,17 @@ public class MooDialog extends JDialog { case DELETE_TRACK: makeDelDialog(pane, tracks); break; case COPY_TRACK: makeCopyDialog(pane, tracks); break; case MOVE_TRACK: makeMoveDialog(pane, tracks); break; - case JUMP: makeJumpDialog(pane); break; - case CONTENTS: makeTextDialog(pane, "Manual.txt"); break; + case SET_POSITION: makeSetPositionDialog(pane); break; + case MANUAL: makeTextDialog(pane, "Manual.txt"); break; + case INSERT_MEASURE: makeInsertMeasureDialog(pane); break; + case DELETE_MEASURE: makeDeleteMeasureDialog(pane); break; } } /** * Builds the add track popupdialog. + * @param pane The container to put the dialog in. + * @param tracks A array containing miditracks. */ private void makeAddDialog(Container pane, Track[] tracks) { @@ -72,16 +78,17 @@ public class MooDialog extends JDialog { 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); + setLocationRelativeTo(Moosique.getGUI()); setVisible(true); } /** * Builds the delete track popupdialog. + * @param pane The container to put the dialog in. + * @param tracks A array containing miditracks. */ private void makeDelDialog(Container pane, Track[] tracks) { @@ -101,16 +108,17 @@ public class MooDialog extends JDialog { 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); + setLocationRelativeTo(Moosique.getGUI()); setVisible(true); } /** * Builds the copy track popupdialog. + * @param pane The container to put the dialog in. + * @param tracks A array containing miditracks. */ private void makeCopyDialog(Container pane, Track[] tracks) { @@ -137,16 +145,17 @@ public class MooDialog extends JDialog { 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); + setLocationRelativeTo(Moosique.getGUI()); setVisible(true); } /** * Builds the move track popupdialog + * @param pane The container to put the dialog in. + * @param tracks A array containing miditracks. */ private void makeMoveDialog(Container pane, Track[] tracks) { @@ -173,21 +182,22 @@ public class MooDialog extends JDialog { 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); + setLocationRelativeTo(Moosique.getGUI()); setVisible(true); } /** - * Builds the jump popupdialog. + * Builds the set position dialog. + * @param pane The container to put the dialog in. + * @param tracks A array containing miditracks. */ - private void makeJumpDialog(Container pane) { + private void makeSetPositionDialog(Container pane) { - setTitle("Jump"); - labelA = new JLabel("Msr", JLabel.CENTER); + setTitle("Set edit position"); + labelA = new JLabel("Measure", JLabel.CENTER); pane.add(labelA); labelB = new JLabel("Beat", JLabel.CENTER); pane.add(labelB); @@ -213,16 +223,84 @@ public class MooDialog extends JDialog { 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); + 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("Contents"); + setTitle("User Manual"); + pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); File manual = new File(filename); String s; try { @@ -233,15 +311,17 @@ public class MooDialog extends JDialog { } catch (Exception ex) { s = "Manual not found"; } - JTextArea contents = new JTextArea(s, 30, 40); - contents.setAutoscrolls(true); - pane.add(contents); - contents.setBounds(10, 10, 500, 350); + 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(); - setSize(600,400); - setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2, - (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2); + setLocationRelativeTo(Moosique.getGUI()); setVisible(true); } @@ -263,7 +343,6 @@ public class MooDialog extends JDialog { 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: ")); @@ -279,7 +358,7 @@ public class MooDialog extends JDialog { velocitypanel, lengthpanel}; - final String btnString1 = "Enter"; + final String btnString1 = "Apply changes"; final String btnString2 = "Cancel"; Object[] options = {btnString1, btnString2}; @@ -335,14 +414,15 @@ public class MooDialog extends JDialog { note.setPitch(Integer.parseInt(pitch.getText())); note.setVelocity(Integer.parseInt(velocity.getText())); note.setDuration(Integer.parseInt(length.getText())); - - setVisible(false); + Moosique.setEdited(); + setVisible(false); } else { // user closed dialog or clicked cancel - setVisible(false); + setVisible(false); } } } }); pack(); + setVisible(true); } }