Displaying Text in a Dialog Box

In this program, will we be showing you how to use JAVA program to display a text using JAVA GUI (Graphics User Interface) in a dialog box.

Typically,dialog boxes are windows in which programs display important messages to the user of the program. 

This application uses Java's Class JOptionPane which provides prepackaged dialog boxes that enables programs to display windows containing messages to its user.

we will be using the import javax.swing.JOptionPane which is an import declaration and is part of the Java API
Programmers use import declarations to identify the predefined classes used in Java Program. The import declaration help the compiler locate the classes you intend to use, this tells the compiler that our program uses class JOptionPane from package javax.swing and this package helps programmers create graphical user interfaces (GUI) for applications.

The program below illustrates how to create a text in a dialog box.

import javax.swing.JOptionPane;  

public class HelloWorld{

  public static void main(String args[])
  {
    JOptionPane.showMessageDialog(null, "Welcome to\nJava Programming!!");
   
    System.exit(0);
  }
}

Java applications can also be run on command prompt.  On Printing Your Fist Java Program we explain the steps with developing your first java program on command prompt.


Comments

Popular posts from this blog

Body Mass Index Calculator In C

Adding two Integers in Java Application

Calculating Product, sum, difference, and quotient of Five Integers