annotate src/treeVnc/ClipboardFrame.java @ 62:b2492abdae2a Version1.0 tip

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