2 // Copyright (C) 2001 HorizonLive.com, Inc. All Rights Reserved.
3 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
5 // This is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This software is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this software; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 import java.awt.event.*;
28 class ClipboardFrame extends Frame
29 implements WindowListener, ActionListener {
32 Button clearButton, closeButton;
40 ClipboardFrame(VncViewer v) {
41 super("TightVNC Clipboard");
45 GridBagLayout gridbag = new GridBagLayout();
48 GridBagConstraints gbc = new GridBagConstraints();
49 gbc.gridwidth = GridBagConstraints.REMAINDER;
50 gbc.fill = GridBagConstraints.BOTH;
53 textArea = new TextArea(5, 40);
54 gridbag.setConstraints(textArea, gbc);
57 gbc.fill = GridBagConstraints.HORIZONTAL;
62 clearButton = new Button("Clear");
63 gridbag.setConstraints(clearButton, gbc);
65 clearButton.addActionListener(this);
67 closeButton = new Button("Close");
68 gridbag.setConstraints(closeButton, gbc);
70 closeButton.addActionListener(this);
74 addWindowListener(this);
79 // Set the cut text from the RFB server.
82 void setCutText(String text) {
84 textArea.setText(text);
92 // When the focus leaves the window, see if we have new cut text and
93 // if so send it to the RFB server.
96 public void windowDeactivated (WindowEvent evt) {
97 if (selection != null && !selection.equals(textArea.getText())) {
98 selection = textArea.getText();
99 viewer.setCutText(selection);
104 // Close our window properly.
107 public void windowClosing(WindowEvent evt) {
112 // Ignore window events we're not interested in.
115 public void windowActivated(WindowEvent evt) {}
116 public void windowOpened(WindowEvent evt) {}
117 public void windowClosed(WindowEvent evt) {}
118 public void windowIconified(WindowEvent evt) {}
119 public void windowDeiconified(WindowEvent evt) {}
123 // Respond to button presses
126 public void actionPerformed(ActionEvent evt) {
127 if (evt.getSource() == clearButton) {
128 textArea.setText("");
129 } else if (evt.getSource() == closeButton) {