Displays a modal dialog with two buttons labeled “Yes” and “No”. These labels are not always terribly descriptive program-specific actions that cause.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/*<APPLET CODE =JavaExampleDialogConfirmInApplet.class WIDTH = 370 HEIGHT = 300></APPLET>*/
public class JavaExampleDialogConfirmInApplet extends JApplet
{
JWindow Wndw = new JWindow();
public void init()
{
final Container cntnr = getContentPane();
JButton BtnShw = new JButton("Show The Dialog ");
cntnr.setLayout(new FlowLayout());
cntnr.add(BtnShw);
BtnShw.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e1)
{
int reslt = JOptionPane.showConfirmDialog((Component)null, "Press Yes or No", "Press Yes or No",JOptionPane.YES_NO_OPTION);
if (reslt == JOptionPane.YES_OPTION)
{
showStatus("You Press Yes.");
}
else
{
showStatus("You Press No.");
}
}
});
}
}