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
Post a Comment
Please feel free to comments if you have any ideas, questions and subjection concerning our post and programs