我在 JFrame 中有一个 JTextField,我希望它在将文件拖入 JTextField 时找到文件的文件路径。我应该使用某种监听器吗?我应该怎么做?
public class UI extends JFrame{
String s;
JTextArea textfield = new JTextArea();
public UI(){
setVisible(true);
setSize(1000,800);
setResizable(false);
setTitle("Cloavy Compiler");
textfield.setSize(1000,800);
add(textfield);
}
public void onDrag(){
s = filepath;
}
}
感谢您的宝贵时间。
最佳答案
在 Drag and Drop and Data Transfer 中寻找答案教程的类(class)。
关于Java - 如何将文件拖放到 JTextArea 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12207523/