I have to display a Jpanel inside a JDialog and so far I dealt with it however I don’t know how to close the dialog and receive the data inside the Jpanel before disposing of it.
newButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
JDialog dialog = new JDialog(Main.getMainFrame(), true);
JPanel jPanel = new JPanel();
dialog.getContentPane().add(jPanel);
dialog.setMinimumSize(new Dimension(600, 800));
dialog.setVisible(true);
if (jPanel.close)
{
/*read some useful information from the jpanel*/
dialog.setVisible(false);
dialog.dispose();
}
}
});
so far I have put a button inside the Jpanel which sets a boolean close = true and the dialog reads it and disposes of itself. However this doesn’t work: I suspect the jPanel.close() is tested before I click close inside the JPanel while it should wait for the actual close value to change.
You can use code like this to get container window instance (
JDialogin our case)