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