Download presentation
Presentation is loading. Please wait.
Published byPoppy Phelps Modified over 9 years ago
1
Java Programming, 3e Concepts and Techniques Chapter 2 Creating a Java Application and Applet
2
Chapter 2: Creating a Java Application and Applet 2 Chapter Objectives Write a simple Java application Understand the different types and uses of comments Use proper naming conventions for classes and files Identify the parts of a class header and method header
3
Chapter 2: Creating a Java Application and Applet 3 Introduction Users enter data and instructions into a computer and receive feedback from the computer through a user interface Programmers can create many types of user interfaces in Java We will create a program with two types of user interfaces –Console application Command line interface –Applet Graphical user interface displayed in a browser
4
Chapter 2: Creating a Java Application and Applet 4 The Welcome to My Day Program This program will display a splash screen –A splash screen is a screen that is displayed before the main program starts The screen will contain a welcome message, user’s name, and system date –The console application will display text only –The applet will contain text, color, and a graphic
5
Chapter 2: Creating a Java Application and Applet 5
6
6 Program Development
7
Chapter 2: Creating a Java Application and Applet 7 Analysis and Design Verify that the requirements are specific enough Design the user interface using a storyboard Design the program logic using a flowchart and event diagram
8
Chapter 2: Creating a Java Application and Applet 8
9
9
10
10
11
Chapter 2: Creating a Java Application and Applet 11 Coding the Program - Comments as Documentation Purpose of comments –Provides clear description when reviewing code –Helps programmer think clearly when coding Placement of comments –Use a comment header to identify a file and its purpose –Place a comment at the beginning of code for each event and method –Place comments near portions of code that need clarification
12
Chapter 2: Creating a Java Application and Applet 12 Coding the Program - Comments as Documentation
13
Chapter 2: Creating a Java Application and Applet 13 Coding the Program - Define the Project For this assignment create a new project called “Welcome” with a class of “welcome.Welcome”
14
Chapter 2: Creating a Java Application and Applet 14 Coding the Program - The Class Header Identify how the code can be accessed with an access modifier –public indicates that the code can be accessed by all objects in the program and can be extended for a subclass Specify a unique name for the class –The class name at the beginning of the program must match the file name exactly –Java is case-sensitive –By convention, uppercase letters are used for class names and to distinguish words in class names
15
Chapter 2: Creating a Java Application and Applet 15 Coding the Program - The Class Header Use braces { } after the class header to enclose the class body
16
Chapter 2: Creating a Java Application and Applet 16 The Welcome Class /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package welcome; /** * * @author gjschmidt */ public class Welcome { }
17
Chapter 2: Creating a Java Application and Applet 17 Rest of Today Make sure you create and save your Welcome project Review your grade. Progress report grades are due on Friday. Make sure your write-up for the Alice project has been turned in.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.