by Dinesh Thakur Category: Swing

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());
         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.");
                              showStatus("You Press No.");

Confirm Dialog Box Java Swing Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article