How to put jpanel in a dialog box?

I need to create a user dialog and put JPanel in it. Is it possible?

+3
source share
2 answers

The panel dialog box inside should have what you need.

+1
source

Maybe you need it

JPanel myPanel = new JPanel();
myPanel.setBounds(0, 0, 400, 450);
myPanel.setBackground(Color.YELLOW);
JOptionPane jop = new JOptionPane();
JDialog dialog = jop.createDialog("This is my Dialog");
dialog.setSize(400, 450);
dialog.setContentPane(myPanel);
dialog.setVisible(true);

I tested this code and worked fine for me ...

0
source

Source: https://habr.com/ru/post/1736896/


All Articles