
Make
Customprompt扩展JDialog,让它的构造函数调用
super传递所有者
Window和所需的ModalityType。
public class Customprompt extends JDialog { public static String showprompt(Window parent, String title, String text, String defaultText) { final Customprompt prompt = new Customprompt(parent); prompt.setTitle(title); // set other components text prompt.setVisible(true); return prompt.textField.getText(); } private JTextField textField; // private if you only want this prompt to be accessible via constructor methods private Customprompt(Window parent) { super(parent, Dialog.DEFAULT_MODALITY_TYPE); // Java >= 6, else user super(frame, true) or super(Dialog, true); initComponents(); // like Netbeans } // initComponents() and irrelevant pre. }欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)