annotate src/myVncProxy/ClipboardFrame.java @ 145:8bdbed4c4505

add template.txt
author e085711
date Mon, 05 Sep 2011 06:03:14 +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 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 // Clipboard frame.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 import java.awt.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27 import java.awt.event.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 class ClipboardFrame extends Frame
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30 implements WindowListener, ActionListener {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 TextArea textArea;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33 Button clearButton, closeButton;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 String selection;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35 VncViewer viewer;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 // Constructor.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 ClipboardFrame(VncViewer v) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 super("TightVNC Clipboard");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 viewer = v;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 GridBagLayout gridbag = new GridBagLayout();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 setLayout(gridbag);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 GridBagConstraints gbc = new GridBagConstraints();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 gbc.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 gbc.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 gbc.weighty = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 textArea = new TextArea(5, 40);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 gridbag.setConstraints(textArea, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 add(textArea);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 gbc.fill = GridBagConstraints.HORIZONTAL;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 gbc.weightx = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 gbc.weighty = 0.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 gbc.gridwidth = 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 clearButton = new Button("Clear");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 gridbag.setConstraints(clearButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 add(clearButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 clearButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 closeButton = new Button("Close");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 gridbag.setConstraints(closeButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 add(closeButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71 closeButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73 pack();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75 addWindowListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 }
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 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80 // Set the cut text from the RFB server.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 void setCutText(String text) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 selection = text;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 textArea.setText(text);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 if (isVisible()) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87 textArea.selectAll();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 // When the focus leaves the window, see if we have new cut text and
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94 // if so send it to the RFB server.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97 public void windowDeactivated (WindowEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 if (selection != null && !selection.equals(textArea.getText())) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99 selection = textArea.getText();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 viewer.setCutText(selection);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 }
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 // Close our window properly.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
107
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
108 public void windowClosing(WindowEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
109 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
110 }
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 // Ignore window events we're not interested in.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116 public void windowActivated(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 public void windowOpened(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
118 public void windowClosed(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
119 public void windowIconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
120 public void windowDeiconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
121
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
122
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
123 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
124 // Respond to button presses
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
125 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
126
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
127 public void actionPerformed(ActionEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
128 if (evt.getSource() == clearButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
129 textArea.setText("");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
130 } else if (evt.getSource() == closeButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
131 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
132 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
133 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
134 }