【发布时间】:2012-08-31 00:42:39
【问题描述】:
我在 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;
}
}
感谢您的宝贵时间。
【问题讨论】:
标签: java swing file drag-and-drop jtextarea