annotate src/ButtonPanel.java @ 0:e04119c40b9b

upload all file of tighVNCClient
author e085711
date Tue, 12 Apr 2011 12:57:33 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
2 // Copyright (C) 2001,2002 HorizonLive.com, Inc. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
3 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
4 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
5 // This is free software; you can redistribute it and/or modify
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
6 // it under the terms of the GNU General Public License as published by
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
7 // the Free Software Foundation; either version 2 of the License, or
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
8 // (at your option) any later version.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
9 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
10 // This software is distributed in the hope that it will be useful,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
13 // GNU General Public License for more details.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
14 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
16 // along with this software; if not, write to the Free Software
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
18 // USA.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
19 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
20
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
21 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
22 // ButtonPanel class implements panel with four buttons in the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
23 // VNCViewer desktop window.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
24 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
25
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
26 import java.awt.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
27 import java.awt.event.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
28 import java.io.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
29
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
30 class ButtonPanel extends Panel implements ActionListener {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
31
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
32 VncViewer viewer;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
33 Button disconnectButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
34 Button optionsButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
35 Button recordButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
36 Button clipboardButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
37 Button ctrlAltDelButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
38 Button refreshButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
39
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
40 ButtonPanel(VncViewer v) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
41 viewer = v;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
42
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
43 setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
44 disconnectButton = new Button("Disconnect");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
45 disconnectButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
46 add(disconnectButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
47 disconnectButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
48 optionsButton = new Button("Options");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
49 add(optionsButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
50 optionsButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
51 clipboardButton = new Button("Clipboard");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
52 clipboardButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
53 add(clipboardButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
54 clipboardButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
55 if (viewer.rec != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
56 recordButton = new Button("Record");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
57 add(recordButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
58 recordButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
59 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
60 ctrlAltDelButton = new Button("Send Ctrl-Alt-Del");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
61 ctrlAltDelButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
62 add(ctrlAltDelButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
63 ctrlAltDelButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
64 refreshButton = new Button("Refresh");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
65 refreshButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
66 add(refreshButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
67 refreshButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
68 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
69
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
70 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
71 // Enable buttons on successful connection.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
72 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
73
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
74 public void enableButtons() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
75 disconnectButton.setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
76 clipboardButton.setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
77 refreshButton.setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
78 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
79
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
80 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
81 // Disable all buttons on disconnect.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
82 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
83
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
84 public void disableButtonsOnDisconnect() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
85 remove(disconnectButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
86 disconnectButton = new Button("Hide desktop");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
87 disconnectButton.setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
88 add(disconnectButton, 0);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
89 disconnectButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
90
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
91 optionsButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
92 clipboardButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
93 ctrlAltDelButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
94 refreshButton.setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
95
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
96 validate();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
97 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
98
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
99 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
100 // Enable/disable controls that should not be available in view-only
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
101 // mode.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
102 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
103
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
104 public void enableRemoteAccessControls(boolean enable) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
105 ctrlAltDelButton.setEnabled(enable);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
106 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
107
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
108 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
109 // Event processing.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
110 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
111
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
112 public void actionPerformed(ActionEvent evt) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
113
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
114 viewer.moveFocusToDesktop();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
115
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
116 if (evt.getSource() == disconnectButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
117 viewer.disconnect();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
118
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
119 } else if (evt.getSource() == optionsButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
120 viewer.options.setVisible(!viewer.options.isVisible());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
121
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
122 } else if (evt.getSource() == recordButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
123 viewer.rec.setVisible(!viewer.rec.isVisible());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
124
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
125 } else if (evt.getSource() == clipboardButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
126 viewer.clipboard.setVisible(!viewer.clipboard.isVisible());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
127
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
128 } else if (evt.getSource() == ctrlAltDelButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
129 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
130 final int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
131
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
132 KeyEvent ctrlAltDelEvent =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
133 new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, 127);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
134 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
135
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
136 ctrlAltDelEvent =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
137 new KeyEvent(this, KeyEvent.KEY_RELEASED, 0, modifiers, 127);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
138 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
139
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
140 } catch (IOException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
141 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
142 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
143 } else if (evt.getSource() == refreshButton) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
144 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
145 RfbProto rfb = viewer.rfb;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
146 rfb.writeFramebufferUpdateRequest(0, 0, rfb.framebufferWidth,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
147 rfb.framebufferHeight, false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
148 } catch (IOException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
149 e.printStackTrace();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
150 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
151 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
152 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
153 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
154