简体   繁体   中英

JFrame and JOptionPane

I have been messing around for a bit now to get this to work how I intend it to work, but couldn't find anything through Google or API to find the answer I seek, so here I am!

The project I am currently working on is an App for soldier registration (Theme of project), I used JFrame and JButton s, but I need to get a dialog box in JFrame that will intake answers. Something that works like this, but is integrated in JFrame :

nameField = JOptionPane.showInputDialog(null, "Enter Username(Default is 000000");

好吧,通过集成到JFrame中,我不太确定你想要对话框做什么,但只需将JOptionPane.showInputDialog()的第一个参数设置为父框架,输入就会有父窗口的图标。

nameField = JOptionPane.showInputDialog(myParentFrame,"Enter Username(Default is 000000");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM