Clipboard « Development « Java Swing Q&A





1. java/swing: clipboard paste    stackoverflow.com

I have a DropTargetListener setup to allow me to drag + drop strings into some tables of my Swing application -- on a drop, I parse the string and insert data ...

2. Is it possible to be informed when clipboard content changes outside of java    stackoverflow.com

The thing I would want to do is that when the user copies a text in any program (firefox, notepad, pdfReader etc.) my already running java application shall be informed and ...

3. Detecting clipboard contents    coderanch.com

4. Need help exporting to clipboard    coderanch.com

import java.awt.*; import javax.swing.*; import java.awt.datatransfer.StringSelection; class Testing extends JFrame { JLabel label = new JLabel("Hello World"); public Testing() { setTitle("Testing"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocation(400,300); setSize(200,100); Container frame = getContentPane(); JPanel jp = new JPanel(); jp.add(label); frame.add(jp); setClipboard(); } public void setClipboard() { StringSelection ss = new StringSelection(label.getText()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null); } public static void main( String[] args){new Testing().setVisible(true);} }

5. Clipboard not copying right data    coderanch.com

6. Clipboard problem    coderanch.com

public static void putIntoClipboard(Object[][] data) { StringBuilder sb = new StringBuilder(); for (int r = 0; r < data.length; r++) { for (int c = 0; c < data[r].length; c++) { sb.append(data[r][c].toString()).append(COLUMN_SEPARATOR); } sb.append(ROW_SEPARATOR); } putStringIntoClipboard(sb.toString()); } static void putStringIntoClipboard(String s) { Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection ss = new StringSelection(s); cb.setContents(ss, ss); }

7. loading content to clipboard    coderanch.com

9. Facing problems with setting value on the Clipboard...    coderanch.com

Hi, May be i dint make my self clear. What i basically want is that the value which is being dragged say "XXX" is supposed to be displayed just below the cursor. Please have a look at the attachment, that should be more helpful i guess.. In my previous post, i was assuming that when drag and drop is being handled, ...





10. Paste inserts 2 copies of clipboard    coderanch.com

Hi all, I have a text field that I want to support the ^C and ^V conventions for copy and paste. The problem is that I get *two* copies of whatever was in the clipboard. The code is so simple that I would think there's not much to go wrong. But clearly I'm wrong... Anyway, the JVM is 1.6.0_18 on a ...