blob: e7cabb58259178ce1f32c35437a188a60504ac4e [file] [log] [blame]
Constantin Kaplinsky1215b992008-04-18 09:51:44 +00001//
Constantin Kaplinsky903009e2002-05-20 10:55:47 +00002// Copyright (C) 2002 HorizonLive.com, Inc. All Rights Reserved.
Constantin Kaplinsky1215b992008-04-18 09:51:44 +00003//
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 Kaplinsky1215b992008-04-18 09:51:44 +000020import java.awt.*;
21import java.awt.event.*;
22import java.io.*;
23
24class ButtonPanel extends Panel implements ActionListener {
25
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000026 protected RfbPlayer player;
27 protected Button playButton;
28 protected Button pauseButton;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000029
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000030 ButtonPanel(RfbPlayer player) {
31 this.player = player;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000032
33 setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000034
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 Kaplinsky1215b992008-04-18 09:51:44 +000044 }
45
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000046 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 Kaplinsky1215b992008-04-18 09:51:44 +000069 }
70
71 //
72 // Event processing.
73 //
74
75 public void actionPerformed(ActionEvent evt) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000076 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 Kaplinsky1215b992008-04-18 09:51:44 +000082 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000083 }
84}
85