Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

java - How to add components to JDialog

   d1=new JDialog();
   d1.setSize(200, 100);
   t1=new JTextField();
   t1.setBounds(10,10,40,20);
   d1.add(t1);

I want to add components in JDialog such as TextField, Button...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

1) first create a Jpanel

JPanel pan=new JPanel();
pan.setLayout(new FlowLayout());

2) add the components to that JPanel

pan.add(new JLabel("label"));
pan.add(new JButton("button"));

3) create JDialog

JDialog jd=new JDialog();

4) add the JPanel to JDialog

jd.add(pan);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...