2 // Copyright (C) 2001,2002 HorizonLive.com, Inc. All Rights Reserved.
3 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
5 // This is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This software is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this software; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // ButtonPanel class implements panel with four buttons in the
23 // VNCViewer desktop window.
27 import java.awt.event.*;
30 class ButtonPanel extends Panel implements ActionListener {
33 Button disconnectButton;
36 Button clipboardButton;
37 Button ctrlAltDelButton;
40 ButtonPanel(VncViewer v) {
43 setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
44 disconnectButton = new Button("Disconnect");
45 disconnectButton.setEnabled(false);
46 add(disconnectButton);
47 disconnectButton.addActionListener(this);
48 optionsButton = new Button("Options");
50 optionsButton.addActionListener(this);
51 clipboardButton = new Button("Clipboard");
52 clipboardButton.setEnabled(false);
54 clipboardButton.addActionListener(this);
55 if (viewer.rec != null) {
56 recordButton = new Button("Record");
58 recordButton.addActionListener(this);
60 ctrlAltDelButton = new Button("Send Ctrl-Alt-Del");
61 ctrlAltDelButton.setEnabled(false);
62 add(ctrlAltDelButton);
63 ctrlAltDelButton.addActionListener(this);
64 refreshButton = new Button("Refresh");
65 refreshButton.setEnabled(false);
67 refreshButton.addActionListener(this);
71 // Enable buttons on successful connection.
74 public void enableButtons() {
75 disconnectButton.setEnabled(true);
76 clipboardButton.setEnabled(true);
77 refreshButton.setEnabled(true);
81 // Disable all buttons on disconnect.
84 public void disableButtonsOnDisconnect() {
85 remove(disconnectButton);
86 disconnectButton = new Button("Hide desktop");
87 disconnectButton.setEnabled(true);
88 add(disconnectButton, 0);
89 disconnectButton.addActionListener(this);
91 optionsButton.setEnabled(false);
92 clipboardButton.setEnabled(false);
93 ctrlAltDelButton.setEnabled(false);
94 refreshButton.setEnabled(false);
100 // Enable/disable controls that should not be available in view-only
104 public void enableRemoteAccessControls(boolean enable) {
105 ctrlAltDelButton.setEnabled(enable);
112 public void actionPerformed(ActionEvent evt) {
114 viewer.moveFocusToDesktop();
116 if (evt.getSource() == disconnectButton) {
119 } else if (evt.getSource() == optionsButton) {
120 viewer.options.setVisible(!viewer.options.isVisible());
122 } else if (evt.getSource() == recordButton) {
123 viewer.rec.setVisible(!viewer.rec.isVisible());
125 } else if (evt.getSource() == clipboardButton) {
126 viewer.clipboard.setVisible(!viewer.clipboard.isVisible());
128 } else if (evt.getSource() == ctrlAltDelButton) {
130 final int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
132 KeyEvent ctrlAltDelEvent =
133 new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, 127);
134 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
137 new KeyEvent(this, KeyEvent.KEY_RELEASED, 0, modifiers, 127);
138 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
140 } catch (IOException e) {
143 } else if (evt.getSource() == refreshButton) {
145 RfbProto rfb = viewer.rfb;
146 rfb.writeFramebufferUpdateRequest(0, 0, rfb.framebufferWidth,
147 rfb.framebufferHeight, false);
148 } catch (IOException e) {