Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Java error dialog

Related Tutorials


 
 

Share on Google+Share on Google+

Java error dialog

Advertisement
A Java dialog box is an independent sub window that is used to notice a temporary message to the user.

Java error dialog

     

A Java dialog box is an independent sub window  that is used to notice a temporary message to the user. The dialog box find its extensive application in image, directory and anything compatible with swing. Now dialog box show an error box that gives an error message or  warning message.To create an error dialog box we need JOptionPane swing.

Understand  with Example

In this section of the Tutorial we want to describe you a code that helps you in understanding how to create an Error dialogs box using Swing JOptionPane.For this we have a class name Errordialogs,Inside the main method we create and assign an instance of class JOptionPane to the memory. Using JOptionSwing we create a customized  dialog box, support  title,text,images and icon.

1)JOptionPane.showMessageDialog(object," Press Ok to exit our" + " from the error dialog box")-This return an Error dialog box with a default title and icon.

2)JOptionPane.showConfirmDialog(null."Click One", Click one,JoptionPane.YES_NO_OPTION)-This return you an optional message that can be can be ok and cancelled the message.This mean ask you a confirm question "Yes" or "No".

Errordialogs.java


import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Errordialogs extends JPanel {

  public static void main(String[] a) {

  JOptionPane jop = new JOptionPane();
  JOptionPane.showMessageDialog(jop, "Press Ok to exit our " +
 "from the error diaolag box");
  JOptionPane.showConfirmDialog(null, "Click one"
  "Click one", JOptionPane.YES_NO_OPTION);
 
  }
}
 

On the execution of code ,The Program code create you an error dialog box with a customized  message on it.
Output


Download code
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 3, 2008

Related Tutorials

Discuss: Java error dialog  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com