List of usage examples for javax.swing JTextArea getTransferHandler
public TransferHandler getTransferHandler()
transferHandler
property. From source file:FileTransferHandler.java
/** * This class demonstrates the FileTransferHandler by installing it on a * JTextArea component and providing a JFileChooser to drag and cut files. *///from w w w . j ava 2s . co m public static void main(String[] args) { // Here's the text area. Note how we wrap our TransferHandler // around the default handler returned by getTransferHandler() JTextArea textarea = new JTextArea(); TransferHandler defaultHandler = textarea.getTransferHandler(); textarea.setTransferHandler(new FileTransferHandler(defaultHandler)); // Here's a JFileChooser, with dragging explicitly enabled. JFileChooser filechooser = new JFileChooser(); filechooser.setDragEnabled(true); // Display them both in a window JFrame f = new JFrame("File Transfer Handler Test"); f.getContentPane().add(new JScrollPane(textarea), "Center"); f.getContentPane().add(filechooser, "South"); f.setSize(400, 600); f.setVisible(true); }