1 inf160 is development environments aubg, cos dept lecture 04 title: computer applications (extract...
TRANSCRIPT
1
INF160 IS Development Environments AUBG, COS dept
Lecture 04Title:
Computer Applications (Extract from Syllabus)
2
Lecture Contents:
Program – definition/description Application – definition/descriptionCategories of applicationsDemo programs/applications
3
Demo Programs:
Group name: Test160aHelloWorldConsole Applications:
Test160aHelloWorldVBTest160aHelloWorldCPPTest160aHelloWorldC#Test160aHelloWorldJava
4
Demo Programs:
Group name: Test160eGUI1GUI Applications:
Test160eGUI1VBTest160eGUI1CPPTest160eGUI1C#Test160eGUI1Java
5
Demo Programs:
Group name: Test160eGUI2GUI Applications:
Test160eGUI2VBTest160eGUI2CPPTest160eGUI2C#Test160eGUI2Java
6
Demo Programs:
Group name: Test160eGUI3GUI Applications: Java Applets
Test160eGUI3Java
7
Program – definition/description
Program: An organized list of instructions that, when executed, causes the computer to behave in a predetermined manner.
A program is like a recipe. It contains a list of ingredients (called variables) and a list of directions (called statements) that tell the computer what to do with the variables. The variables can represent numeric data, text, or graphical images.
Without programs, computers are useless.
8
Application – definition/description
Application: A program or a group of programs designed for end users.
Application software can be divided into two general classes: Systems software Application software.
for details, open next 2 slides
9
Application – definition/description
Systems software consists of low-level programs that interact with the computer at a very basic level. This includes:
Operating Systems components,
Compilers or Language Processors,
Uutilities for managing computer resources.
10
Application – definition/description
In contrast, application software (also called end-user programs) includes:
Data Base programs, Word processors,Spreadsheets etc.Figuratively speaking, applications software
sits on top of systems software because it is unable to run without the operating system and system utilities.
11
12
Enterprise application
Enterprise application, or
Enterprise software, or
Enterprise Application Software (EAS) are all commonly used phrases i.e. synonyms to describe applications -- or software -- that a business would use to assist the organization in solving enterprise problems.
13
Categories of applications – primitive elementary classified
Console Applications
Windows GUI Applications
Web based (Internet) Applications
14
Categories of applications – more precise classification
Most IDEs come with a package of wizards that generate starting code for wide variety of applications
Console ApplicationsWindows GUI ApplicationsWeb based (Internet) ApplicationsServicesClass librariesOther special applications
15
Categories of applications – more precise classification
Console Applications Run in a command prompt And are text – only Reading from the keyboard Writing to the screen
16
Categories of applications – more precise classification
Windows GUI Applications Are graphical applications Use mouse and keyboard for generating events Use Windows controls such as labels, text boxes,
buttons, check boxes, radio buttons etc.
17
Categories of applications – more precise classification
Web based (Internet) Applications Run on a Web server When a particular URL is loaded Send HTML as response to a request from a
waiting browser
18
Categories of applications – more precise classification
Services Applications that run in the background And respond to requests But have no any visual user interface
19
Categories of applications – more precise classification
Class libraries Are collections of code that can be called by other
code. Static libraries (.lib, .a) Dynamic libraries (.dll)
20
You can create several different types of programs using C#.
For example,
•.NET console application running on Windows.
•.NET graphical user interface (GUI) application running on Windows (desktop applications).
•ASP.NET web application running on Internet Information Services (IIS).
21C# Programming: From Problem Analysis to Program Design 21
Types of Applications Developed with C#
Web applications
Windows graphical user interface (GUI) applications
Console-based applications
Class libraries and stand-alone components (.dlls)
Smart device applications
Services
22C# Programming: From Problem Analysis to Program Design 22
Types of Applications Developed with Java
Java programs may be applications or applets.
Applications are standalone programs, similar to .NET Console applications and/or Windows based GUI applications.
Applets are similar to applications, but they do not run as standalone programs.
- Instead, applets adhere to a set of conventions that lets them run within a Java-compatible browser (client-side).
- You can only run an applet from an HTML page.
2323Java Programming: From Problem Analysis to Program Design, 4e
INTRO to Graphical User Interface (GUI) Components
Computing Process models I P O Client Server
JAVA I-P-O Applications classified: Console applications
• Input data, output data displayed in MSDOS window Windowed applications
• Using dialog boxes for input/output (class JOptionPane and methods) Windows based GUI applications
• Using Swing class library components: windows, labels, text fields, buttons etc.
2424Java Programming: From Problem Analysis to Program Design, 4e
INTRO to Graphical User Interface (GUI) Components
Drawbacks/disadvantages of Console applications Dialog boxes based windowed applications
Suppose, the user/developer wants the program to display all input data and output data in one pane or window or dialog box
Java calls such a dialog box GUI or simply UI
2525Java Programming: From Problem Analysis to Program Design, 4e
Graphical User Interface (GUI) Components
Advantages of using GUI: View inputs and outputs simultaneously One graphical window Input values typed in any order Change input values in window Click on buttons to get output
2626Java Programming: From Problem Analysis to Program Design, 4e
Graphical User Interface (GUI) Components
Terminology:Frame
Title bar• System supported icons
• Title Content pane
• Components – labels, text fields, buttons etc
27
Web based (Internet) Applications
C
28
Web Applications
C# Programming: From Problem Analysis to Program Design 28
Figure 1-14 Web application written using C#
29C# Programming: From Problem Analysis to Program Design 29
Web Applications (continued)
C# was designed with the Internet applications in mind
Can quickly build applications that run on the Web with C#
Using Web Forms: part of ASP.NET
30
Windows GUI Applications
C
31C# Programming: From Problem Analysis to Program Design 31
Windows Applications
Applications designed for the desktop
Designed for a single platform
Use classes from System.Windows.Form
Applications can include menus, pictures, drop-down controls, buttons, text boxes, and labels
Use drag-and-drop feature of Visual Studio
32C# Programming: From Problem Analysis to Program Design 32
Windows Applications (continued)
Figure 1-15 Windows application written using C#
33
Console Applications
C
34C# Programming: From Problem Analysis to Program Design 34
Console Applications
Normally read input data from the keyboard
Display text on the command console
Easiest to create
Simplest approach to learning software development
Minimal overhead for input and output of data
35
Demo Programs:
Console Applications:
36
Demo Programs:
Group name: Test160aHelloWorldConsole Applications:
Test160aHelloWorldVB Source text Demo execution
37
Demo Programs:
Group name: Test160aHelloWorldConsole Applications:
Test160aHelloWorldCPP
38
Demo Programs:
Group name: Test160aHelloWorldConsole Applications:
Test160aHelloWorldC#
39
Demo Programs:
Group name: Test160aHelloWorldConsole Applications:
Test160aHelloWorldJava
40
Demo Programs:
GUI Applications:
41
Demo Programs:
Group name: Test160eGUI1GUI Applications:
Test160eGUI1VBTest160eGUI2VB
42
Demo Programs:
Group name: Test160eGUI1GUI Applications:
Test160eGUI1CPPTest160eGUI2CPP
43
Demo Programs:
Group name: Test160eGUI1GUI Applications:
Test160eGUI1C#Test160eGUI2C#
44
Demo Programs:
Group name: Test160eGUI1GUI Applications:
Test160eGUI1JavaTest160eGUI2Java
45
Java Demo Programs:
GUI Applications:
Pure empty frame displayed
PureFrame.java
46
Java Demo Programs:
GUI Applications:
Frame includes: 3 labels, 3 text boxes, 2 buttons
Proben14.java
47
Demo Programs:
JAVA Applets:
48
Demo Programs:
Group name: Test160eGUI3GUI Applications: Java Applets
Test160eGUI3Java
49
Demo Programs:
Applets:
Pure empty frame displayed using AppletViewer utility
WelcomeApplet.java
50
Demo Programs:
Applets:
Pure empty frame displayed using Web browser utility
WelcomeApplet.javaWelcomeApplet.html
51
Demo Programs:
Applets:
Frame includes 2 labels, 2 textfields and displayed using AppletViewer utility
TempConvertApplet.java
52
Demo Programs:
Applets:
Frame includes 2 labels, 2 textfields and displayed using Web browser utility
TempConvertApplet.javaTempConvertApplet.html
53
Thank You For
Your Attention!
54Java Programming, Fifth Edition 54
Introducing Applets
Applets Java programs called from within another
application Frequently run from a Web page Display as rectangular area Can respond to user-initiated events Behaviors come from Java class named JApplet
55Java Programming, Fifth Edition 55
Introducing Applets (continued)
Similar to Java application .java file extension Compile into bytecode using the javac command Saved with .class extension Can contain:
• Methods you define
• Variables and constants
• Decisions, loops, and arrays
• GUI elements
56
Introducing Applets (continued)
Different from a Java application Descend from the JApplet class Run from another application
• Do not use the java command to execute an applet Do not contain a main() method Do not set a default close operation Cannot delete, read, or create files on the user’s system Cannot run any other program on the user’s system
Java Programming, Fifth Edition 56
57
Understanding the JApplet Class
Import JApplet import javax.swing.JApplet;
JApplet Swing class
Skeletal structure of a typical Applet
Java Programming, Fifth Edition 57
import java.awt.Graphics;import javax.swing.JApplet;public class WelcomeApplet extends JApplet{
}
58
Running an Applet
Run applet from a document usually in HTMLHTML, or Hypertext Markup Language
Simple language used to create Web pages for the Internet Contains many commands
Run an applet In a Web browser Applet Viewer
•appletviewer command
Java Programming, Fifth Edition 58
59Java Programming, Fifth Edition 59
Writing an HTML Documentto Host an AppletWhen you create an applet
Write applet in Java• Save with .java file extension
Compile applet into bytecode using javac command Write HTML document
• Includes statement to call compiled Java class Load HTML document into a Web browser
• Or run Applet Viewer program
60Java Programming, Fifth Edition 60
Writing an HTML Documentto Host an Applet (continued)Web browser
Program allows display of HTML documents Often contains Java applets
Untrusted code Carries possibility of doing harm Applet code not trusted
Sandbox Safe area in which applet code can run
61Java Programming, Fifth Edition 61
Writing an HTML Documentto Host an Applet (continued)Run applet from within HTML document
<HTML>
<object code="AClass.class" width=300 height=200> </object>
</HTML>
Three object tag attributes code
• Name of compiled applet width height
62Java Programming, Fifth Edition 62
Writing an HTML Documentto Host an Applet (continued)
Pixels Control size of applet Set with width and height Tiny dots of light
• Make up image on video monitor
Tag set <applet> and </applet> Use instead of <object> tag Better to use <object> tag
63Java Programming, Fifth Edition 63
Creating a JApplet Containingan init() Method
JApplet class methods Invoked by Web browser when browser runs applet public void init() public void start() public void paint() public void stop() public void destroy()
64
Creating a JApplet Containingan init() Method (continued)
Java Programming, Fifth Edition 64
65Java Programming, Fifth Edition 65
Understanding the JAppletLife Cycle
Applets are popular Easy to use in Web pages
JApplet class Contains methods automatically called by browser
•init()•start()•stop()•destroy()
66Java Programming, Fifth Edition 66
Understanding the JAppletLife Cycle (continued)
init() method Executes when Web page containing a JApplet
loaded Or when running appletviewer command
start() method Executes after init() method Executes again every time applet becomes active
after it has been inactive
67Java Programming, Fifth Edition 67
Understanding the JAppletLife Cycle (continued)
stop() method Invoked when user leaves Web page
destroy() method Called when user closes browser or Applet Viewer Releases any resources JApplet might have
allocated
Every JApplet has the same life cycle outline
68
Understanding the JAppletLife Cycle (continued)
Java Programming, Fifth Edition 68
69Java Programming: From Problem Analysis to Program Design, 4e 69
Differences Between Applets and GUI Applications
Applets Class extends JApplet No main method Uses init method Displayed by HTML Sets title in HTML Size set in HTML Applet closes when HTML
doc closes
GUI applications class extends JFrame Invokes main method Uses constructors Uses method setVisible Uses setTitle method Uses method setSize Closes with Exit button