annotate src/ClipboardFrame.java @ 0:e04119c40b9b

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