X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooToolbar.java;h=1ea47ab08f5e3af9becb759089bc58889cdda5ef;hb=f520dce96c76f627677c5d9957e8371d02a31ec0;hp=a94aabdf8ef0138af880d5592a39c830c6fbd0fd;hpb=83ec11f99e143607d057db2a68c262ca9672e524;p=moosique.git diff --git a/MooToolbar.java b/MooToolbar.java index a94aabd..1ea47ab 100644 --- a/MooToolbar.java +++ b/MooToolbar.java @@ -24,6 +24,7 @@ public class MooToolbar extends JToolBar { */ public MooToolbar() { + setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); setFloatable(false); mouseAdapter = new MAdapter(); @@ -100,17 +101,18 @@ public class MooToolbar extends JToolBar { ticksPerBeat = Moosique.getSequence().getResolution(); } - /* - * Creates a button with the specified image and tooltip. + /** + * Creates a button with the specified image and action command / tooltip. */ - private JButton createButton(String imagelocation, String tooltip) { + private JButton createButton(String imagelocation, String command) { JButton button = new JButton (new ImageIcon(imagelocation)); - button.setToolTipText(tooltip); + button.setToolTipText(command); + button.setActionCommand(command); button.addMouseListener(mouseAdapter); return button; } - /* + /** * Creates labels with the specified text and font size. */ private JLabel createLabel(String title, int fontSize){ @@ -119,7 +121,7 @@ public class MooToolbar extends JToolBar { return label; } - /* + /** * Formats the given label for the progress indicator. */ private JLabel formatProgInd(JLabel label){ @@ -132,20 +134,29 @@ public class MooToolbar extends JToolBar { class MAdapter extends MouseAdapter { public void mouseClicked(MouseEvent e) { if (e.getSource() instanceof JButton) { - String toolTip = ((JButton)e.getSource()).getToolTipText(); - if (toolTip == "Play") { + String command = ((JButton)e.getSource()).getActionCommand(); + if (command == "Play") { playpause.setIcon(pauseIcon); + playpause.setActionCommand("Pause"); playpause.setToolTipText("Pause"); Moosique.play(); - } else if (toolTip == "Pause") { + } else if (command == "Pause") { playpause.setIcon(playIcon); + playpause.setActionCommand("Resume"); playpause.setToolTipText("Resume"); Moosique.pause(); - } else if (toolTip == "Resume") { + } else if (command == "Resume") { playpause.setIcon(pauseIcon); + playpause.setActionCommand("Pause"); playpause.setToolTipText("Pause"); Moosique.resume(); - } else if (toolTip == "Stop") { + } else if (command == "Rewind") { + // Different implementation, perhaps? + Moosique.setEditPosition(0); + Moosique.stop(); + } else if (command == "Fast forward") { + + } else if (command == "Stop") { Moosique.stop(); } } else if (e.getSource() instanceof JLabel) {