You are here:   HomeJava ProgrammingSwing Change Component Location While Clicking Button In Java Swing
by Dinesh Thakur Category: Swing

A confirmation dialog box is meant for asking a confirmation question and allows the user to give a yes/no/cancel response. It is created by using the static method showConfirmDialog() of JOptionPane. The general form of showConfirmDialog()method is

public static int showConfirmDialog(Component parentComponent,

Object message)

where,

parentComponent is the frame to which the dialog box is attached

message is the message to be displayed

 

import javax.swing.JOptionPane;

public class JavaExampleOptionPaneAirlineDialog
  {
   public static void main(String[] as)
    {
      int Slctn;
      boolean Yes;
      Slctn = JOptionPane.showConfirmDialog(null,"Would you Like To Choose Business Class?");
              Yes = (Slctn == JOptionPane.YES_OPTION);
      JOptionPane.showMessageDialog(null,"You Confirmed: " +Yes);
    }
  }

showConfirmDialog Java Example



Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes 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.



What's New and Popular





Popular Article