annotate src/ClipboardFrame.java @ 0:30bb7074acb1

upload all file of tighVNCProxy
author e085711
date Tue, 12 Apr 2011 12:58:05 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
1 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 // Copyright (C) 2001 HorizonLive.com, Inc. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 // This is free software; you can redistribute it and/or modify
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // it under the terms of the GNU General Public License as published by
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 // the Free Software Foundation; either version 2 of the License, or
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 // (at your option) any later version.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 // GNU General Public License for more details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // along with this software; if not, write to the Free Software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 // USA.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19 //
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 // Clipboard frame.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 import java.awt.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 import java.awt.event.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28 class ClipboardFrame extends Frame
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 implements WindowListener, ActionListener {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31 TextArea textArea;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 Button clearButton, closeButton;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33 String selection;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 VncViewer viewer;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 // Constructor.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40 ClipboardFrame(VncViewer v) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 super("TightVNC Clipboard");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42
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 GridBagLayout gridbag = new GridBagLayout();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 setLayout(gridbag);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 GridBagConstraints gbc = new GridBagConstraints();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 gbc.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 gbc.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 gbc.weighty = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 textArea = new TextArea(5, 40);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 gridbag.setConstraints(textArea, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 add(textArea);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 gbc.fill = GridBagConstraints.HORIZONTAL;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 gbc.weightx = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 gbc.weighty = 0.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 gbc.gridwidth = 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62 clearButton = new Button("Clear");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 gridbag.setConstraints(clearButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 add(clearButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 clearButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 closeButton = new Button("Close");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 gridbag.setConstraints(closeButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 add(closeButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 closeButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72 pack();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74 addWindowListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75 }
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 // Set the cut text from the RFB server.
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 void setCutText(String text) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 selection = text;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 textArea.setText(text);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 if (isVisible()) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 textArea.selectAll();
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
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 // When the focus leaves the window, see if we have new cut text and
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 // if so send it to the RFB server.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96 public void windowDeactivated (WindowEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97 if (selection != null && !selection.equals(textArea.getText())) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 selection = textArea.getText();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99 viewer.setCutText(selection);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 }
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 // Close our window properly.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
105 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
107 public void windowClosing(WindowEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
108 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
109 }
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 // Ignore window events we're not interested in.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
113 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115 public void windowActivated(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116 public void windowOpened(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 public void windowClosed(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
118 public void windowIconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
119 public void windowDeiconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
120
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 // Respond to button presses
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
124 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
125
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
126 public void actionPerformed(ActionEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
127 if (evt.getSource() == clearButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
128 textArea.setText("");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
129 } else if (evt.getSource() == closeButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
130 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
131 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
132 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
133 }