Hi,
Following example of java will depict you the use of JDialog class
Code:
import javax.swing.JDialog;
import javax.swing.JPanel;
public class AboutDialogDM extends JDialog implements ActionListener
{
public AboutDialog(JFrame parent, String title, String message) {
super(parent, title, true);
if (parent != null) {
Dimension parentSize = parent.getSize();
Point p1 = parent.getLocation();
setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
}
JPanel messagePane01 = new JPanel();
messagePane01.add(new JLabel(message));
getContentPane().add(messagePane01);
JPanel button01Pane01 = new JPanel();
JButton button01 = new JButton("OK");
button01Pane01.add(button01);
button01.addActionListener(this);
getContentPane().add(button01Pane01, BorderLayout.SOUTH);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
public static void main(String[] abn) {
AboutDialog dlg1 = new AboutDialog(new JFrame(), "title", "message");
}
}
Bookmarks