annotate src/myVncProxy/ButtonPanel.java @ 120:5e3487f06e22

update AcceptClient.java
author Yu Taninari <e085734@ie.u-ryukyu.ac.jp>
date Sun, 07 Aug 2011 05:51:12 +0900
parents 87b29d6039a6
children 134deb9f8148
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;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 ButtonPanel(VncViewer v) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 viewer = v;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 disconnectButton = new Button("Disconnect");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 disconnectButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 add(disconnectButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 disconnectButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 optionsButton = new Button("Options");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 add(optionsButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 optionsButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 clipboardButton = new Button("Clipboard");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 clipboardButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 add(clipboardButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 clipboardButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 if (viewer.rec != null) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 recordButton = new Button("Record");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 add(recordButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 recordButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 ctrlAltDelButton = new Button("Send Ctrl-Alt-Del");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62 ctrlAltDelButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 add(ctrlAltDelButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 ctrlAltDelButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 refreshButton = new Button("Refresh");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 refreshButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 add(refreshButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 refreshButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72 // Enable buttons on successful connection.
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 public void enableButtons() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 disconnectButton.setEnabled(true);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 clipboardButton.setEnabled(true);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78 refreshButton.setEnabled(true);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 // Disable all buttons on disconnect.
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 public void disableButtonsOnDisconnect() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 remove(disconnectButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87 disconnectButton = new Button("Hide desktop");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 disconnectButton.setEnabled(true);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89 add(disconnectButton, 0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90 disconnectButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 optionsButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 clipboardButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94 ctrlAltDelButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 refreshButton.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97 validate();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 // Enable/disable controls that should not be available in view-only
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
102 // mode.
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 public void enableRemoteAccessControls(boolean enable) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106 ctrlAltDelButton.setEnabled(enable);
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 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
110 // Event processing.
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 public void actionPerformed(ActionEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115 viewer.moveFocusToDesktop();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 if (evt.getSource() == disconnectButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
118 viewer.disconnect();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
119
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
120 } else if (evt.getSource() == optionsButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
121 viewer.options.setVisible(!viewer.options.isVisible());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
122
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
123 } else if (evt.getSource() == recordButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
124 viewer.rec.setVisible(!viewer.rec.isVisible());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
125
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
126 } else if (evt.getSource() == clipboardButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
127 viewer.clipboard.setVisible(!viewer.clipboard.isVisible());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
128
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
129 } else if (evt.getSource() == ctrlAltDelButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
130 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
131 final int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
132
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
133 KeyEvent ctrlAltDelEvent =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
134 new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, 127);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
135 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
136
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
137 ctrlAltDelEvent =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
138 new KeyEvent(this, KeyEvent.KEY_RELEASED, 0, modifiers, 127);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
139 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
140
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
141 } catch (IOException e) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
142 e.printStackTrace();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
143 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
144 } else if (evt.getSource() == refreshButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
145 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
146 RfbProto rfb = viewer.rfb;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
147 rfb.writeFramebufferUpdateRequest(0, 0, rfb.framebufferWidth,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
148 rfb.framebufferHeight, false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
149 } catch (IOException e) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
150 e.printStackTrace();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
151 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
152 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
153 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
154 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
155