123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import java.awt.*;
- import java.awt.event.*;
- class ClipboardFrame extends Frame
- implements WindowListener, ActionListener {
- TextArea textArea;
- Button clearButton, closeButton;
- String selection;
- VncViewer viewer;
-
-
-
- ClipboardFrame(VncViewer v) {
- super("Ultr@VNC Clipboard");
- viewer = v;
- GridBagLayout gridbag = new GridBagLayout();
- setLayout(gridbag);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.weighty = 1.0;
- textArea = new TextArea(5, 40);
- gridbag.setConstraints(textArea, gbc);
- add(textArea);
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.gridwidth = 1;
- clearButton = new Button("Clear");
- gridbag.setConstraints(clearButton, gbc);
- add(clearButton);
- clearButton.addActionListener(this);
- closeButton = new Button("Close");
- gridbag.setConstraints(closeButton, gbc);
- add(closeButton);
- closeButton.addActionListener(this);
- pack();
- addWindowListener(this);
- }
-
-
-
- void setCutText(String text) {
- selection = text;
- textArea.setText(text);
- if (isVisible()) {
- textArea.selectAll();
- }
- }
-
-
-
-
- public void windowDeactivated (WindowEvent evt) {
- if (selection != null && !selection.equals(textArea.getText())) {
- selection = textArea.getText();
- viewer.setCutText(selection);
- }
- }
-
-
-
- public void windowClosing(WindowEvent evt) {
- setVisible(false);
- }
-
-
-
- public void windowActivated(WindowEvent evt) {}
- public void windowOpened(WindowEvent evt) {}
- public void windowClosed(WindowEvent evt) {}
- public void windowIconified(WindowEvent evt) {}
- public void windowDeiconified(WindowEvent evt) {}
-
-
-
- public void actionPerformed(ActionEvent evt) {
- if (evt.getSource() == clearButton) {
- textArea.setText("");
- } else if (evt.getSource() == closeButton) {
- setVisible(false);
- }
- }
- }
|