List of usage examples for javax.swing JTextField getSelectionEnd
@Transient public int getSelectionEnd()
From source file:TextCutPaste.java
/** * Bundle up the data for export.// ww w . ja v a2 s .c o m */ protected Transferable createTransferable(JComponent c) { JTextField source = (JTextField) c; int start = source.getSelectionStart(); int end = source.getSelectionEnd(); Document doc = source.getDocument(); if (start == end) { return null; } try { p0 = doc.createPosition(start); p1 = doc.createPosition(end); } catch (BadLocationException e) { System.out.println("Can't create position - unable to remove text from source."); } String data = source.getSelectedText(); return new StringSelection(data); }