如何将组件添加到JDialog [英] How to add components to JDialog
本文介绍了如何将组件添加到JDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
d1=new JDialog();
d1.setSize(200, 100);
t1=new JTextField();
t1.setBounds(10,10,40,20);
d1.add(t1);
我想在JDialog中添加组件,例如TextField,Button ...
I want to add components in JDialog such as TextField, Button...
推荐答案
1)首先创建一个Jpanel
1) first create a Jpanel
JPanel pan=new JPanel();
pan.setLayout(new FlowLayout());
2)将组件添加到该JPanel
2) add the components to that JPanel
pan.add(new JLabel("label"));
pan.add(new JButton("button"));
3)创建JDialog
3) create JDialog
JDialog jd=new JDialog();
4)将JPanel添加到JDialog
4) add the JPanel to JDialog
jd.add(pan);
这篇关于如何将组件添加到JDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文