没听清楚,是不是界面上同时存在button 和 textfield啊,那样直接在button响应函数中调用JTextField.getText()就行了
要是想弹出输入窗口,可以使用JOptionPane的输入对话框