source: other-projects/trunk/gs3-release-maker/tasks/sshtaskdef/src/mindbright/vnc/clipboardFrame.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.5 KB
Line 
1//
2// Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
3//
4// This is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This software is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this software; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17// USA.
18//
19
20//
21// Clipboard frame.
22//
23package mindbright.vnc;
24
25import java.awt.*;
26
27import mindbright.application.MindVNC;
28
29public class clipboardFrame extends Frame {
30
31 TextArea ta;
32 Button clear, dismiss;
33 String selection;
34 MindVNC v;
35
36
37 //
38 // Constructor.
39 //
40
41 public clipboardFrame(MindVNC v1) {
42 super("VNC Clipboard");
43
44 v = v1;
45
46 GridBagLayout gridbag = new GridBagLayout();
47 setLayout(gridbag);
48
49 GridBagConstraints gbc = new GridBagConstraints();
50 gbc.gridwidth = GridBagConstraints.REMAINDER;
51 gbc.fill = GridBagConstraints.BOTH;
52 gbc.weighty = 1.0;
53
54 ta = new TextArea(5,40);
55 gridbag.setConstraints(ta,gbc);
56 add(ta);
57
58 gbc.fill = GridBagConstraints.HORIZONTAL;
59 gbc.weightx = 1.0;
60 gbc.weighty = 0.0;
61 gbc.gridwidth = 1;
62 clear = new Button("Clear");
63 gridbag.setConstraints(clear,gbc);
64 add(clear);
65
66 dismiss = new Button("Dismiss");
67 gridbag.setConstraints(dismiss,gbc);
68 add(dismiss);
69
70 pack();
71 }
72
73
74 //
75 // Set the cut text from the RFB server.
76 //
77
78 void setCutText(String text) {
79 selection = text;
80 ta.setText(text);
81 if (isVisible()) {
82 ta.selectAll();
83 }
84 }
85
86
87 //
88 // When the focus leaves the window, see if we have new cut text and if so
89 // send it to the RFB server.
90 //
91
92 public boolean lostFocus(Event evt, Object arg) {
93 if ((selection != null) && !selection.equals(ta.getText())) {
94 selection = ta.getText();
95 v.setCutText(selection);
96 }
97 return true;
98 }
99
100
101 //
102 // Respond to an action i.e. button press
103 //
104
105 public boolean action(Event evt, Object arg) {
106
107 if (evt.target == dismiss) {
108 hide();
109 return true;
110
111 } else if (evt.target == clear) {
112 ta.setText("");
113 return true;
114 }
115
116 return false;
117 }
118}
Note: See TracBrowser for help on using the repository browser.