annotate src/myVncProxy/ButtonPanel.java @ 184:134deb9f8148

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