Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 861
uday gowda Avatar asked Dec 26 '22 22:12

uday gowda


1 Answers

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);
like image 76
padman Avatar answered Jan 10 '23 09:01

padman