经过数小时的代码挖掘和Web浏览以寻找解决方案之后,我决定将我的问题发布在这里。
我目前正在使用Java 8u45。我需要允许从TextField和拖动选定的文本TextArea。尽管它可以正常运行TextField,但不能运行TextArea-选择在拖动之前就更改了。
在一些工作示例下面-只需选择部分文本并将其拖到例如记事本的某个位置即可:
public class DnD extends Application
{
private static final GridPane rootPane = new GridPane();
private TextField textField;
private TextArea textArea;
public static void main( final String[] args )
{
launch( args );
}
@Override
public void start( final Stage primaryStage )
{
primaryStage.setTitle( "Drag and Drop Application" );
buildGui();
installDnd();
primaryStage.setScene( new Scene( rootPane, 400, 325 ) );
primaryStage.show();
}
private void installDnd()
{
textField.setOnDragDetected( e -> { …Run Code Online (Sandbox Code Playgroud)