Web hosting - 66 Introduction to Java Applications Chapter 2 1

66 Introduction to Java Applications Chapter 2 1 // Fig. 2.6: Welcome4.java 2 // Printing multiple lines in a dialog box 3 4 // Java extension packages 5 import javax.swing.JOptionPane; // import class JOptionPane 6 7 public class Welcome4 { 8 9 // main method begins execution of Java application 10 public static void main( String args[] ) 11 { 12 JOptionPane.showMessageDialog( 13 null, “WelcomentonJavanProgramming!” ); 14 15 System.exit( 0 ); // terminate application 16 17 } // end method main 18 19 } // end class Welcome4 Fig. 2.6Displaying multiple lines in a dialog box. Fig. 2. We will provide an overview of the use of this documentation with the downloads and resources for Java How to Program, Fourth Edition on our Web site, www.deitel.com. Packages are discussed in detail in Chapter 8, Object-Based Programming. Common Programming Error 2.7 All importstatements must appear before the class definition. Placing an importstatement inside a class definition s body or after a class definition is a syntax error. Line 5 tells the compiler to load the JOptionPane class from the javax.swing package. This package contains many classes that help Java programmers define graphical user interfaces (GUIs) for their application. GUI components facilitate data entry by the user of your program and formatting or presentation of data outputs to the user of your program. For example, Fig. 2.7 contains a Netscape Navigator window. In the window, there is a bar containing menus (File, Edit, View, etc.), called a menu bar. Below the menu bar is a set of buttons that each have a defined task in Netscape Navigator. Below the buttons there is a text field in which the user can type the name of the World Wide Web site to visit. The menus, buttons and text fields are part of Netscape Navigator s GUI. They enable you to interact with the Navigator program. Java contains classes that implement the GUI components described here and others that will be described in Chapter 12, Basic Graphical User Interface Components, and Chapter 13, Advanced Graphical User Interface Components. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

Leave a Reply