Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 1 | // |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 2 | // Copyright (C) 2002 HorizonLive.com, Inc. All Rights Reserved. |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 3 | // |
| 4 | // This is free software; you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation; either version 2 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This software is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this software; if not, write to the Free Software |
| 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | // USA. |
| 18 | // |
| 19 | |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 20 | import java.awt.*; |
| 21 | import java.awt.event.*; |
| 22 | import java.io.*; |
| 23 | |
| 24 | class ButtonPanel extends Panel implements ActionListener { |
| 25 | |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 26 | protected RfbPlayer player; |
| 27 | protected Button playButton; |
| 28 | protected Button pauseButton; |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 29 | |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 30 | ButtonPanel(RfbPlayer player) { |
| 31 | this.player = player; |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 32 | |
| 33 | setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 34 | |
| 35 | playButton = new Button("Play"); |
| 36 | playButton.setEnabled(false); |
| 37 | add(playButton); |
| 38 | playButton.addActionListener(this); |
| 39 | |
| 40 | pauseButton = new Button("Pause"); |
| 41 | pauseButton.setEnabled(false); |
| 42 | add(pauseButton); |
| 43 | pauseButton.addActionListener(this); |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 46 | public void setMode(int mode) { |
| 47 | switch(mode) { |
| 48 | case RfbPlayer.MODE_PLAYBACK: |
| 49 | playButton.setLabel("Stop"); |
| 50 | playButton.setEnabled(true); |
| 51 | pauseButton.setLabel("Pause"); |
| 52 | pauseButton.setEnabled(true); |
| 53 | break; |
| 54 | case RfbPlayer.MODE_PAUSED: |
| 55 | playButton.setLabel("Stop"); |
| 56 | playButton.setEnabled(true); |
| 57 | pauseButton.setLabel("Resume"); |
| 58 | pauseButton.setEnabled(true); |
| 59 | break; |
| 60 | default: |
| 61 | // case RfbPlayer.MODE_STOPPED: |
| 62 | playButton.setLabel("Play"); |
| 63 | playButton.setEnabled(true); |
| 64 | pauseButton.setLabel("Pause"); |
| 65 | pauseButton.setEnabled(false); |
| 66 | break; |
| 67 | } |
| 68 | player.setMode(mode); |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | // |
| 72 | // Event processing. |
| 73 | // |
| 74 | |
| 75 | public void actionPerformed(ActionEvent evt) { |
Constantin Kaplinsky | 903009e | 2002-05-20 10:55:47 +0000 | [diff] [blame] | 76 | if (evt.getSource() == playButton) { |
| 77 | setMode((player.getMode() == RfbPlayer.MODE_STOPPED) ? |
| 78 | RfbPlayer.MODE_PLAYBACK : RfbPlayer.MODE_STOPPED); |
| 79 | } else if (evt.getSource() == pauseButton) { |
| 80 | setMode((player.getMode() == RfbPlayer.MODE_PAUSED) ? |
| 81 | RfbPlayer.MODE_PLAYBACK : RfbPlayer.MODE_PAUSED); |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 82 | } |
Constantin Kaplinsky | 1215b99 | 2008-04-18 09:51:44 +0000 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |