java the beginning. why java? currently, this is the language of the international ap course which...

13
Java The Beginning

Upload: francine-fowler

Post on 12-Jan-2016

248 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

JavaThe Beginning

Page 2: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Why Java? Currently, this is the language of the

international AP course which runs Feb-Apr FREE! Platform-independent Simple to learn but powerful Used in Flash Actionscript Used in Android programming

Page 3: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

What can Java do?Java can be used to develop many types of applications.

Java Applications are standalone programs that run on the desktop. They can be: Console apps simple, text-based programs that

support text IO to the monitor GUI apps can have menus, toolbars, buttons,

etc.

Applets run in a browser and easily shared over the Internet.

Page 4: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Java AppletIn Jcreator, create a new workspace named Applets. Save your applets into this workspace. Each new applet will be a new project. Create a new Basic Java Applet. Replace all the code in it with the code from below. Note the corresponding htm file that is created for you, saving you creating it manually.

Page 5: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Java filenames must match the class name exactly.

Java is case-sensitive Java code is compiled, creating a file with

the .class extension. You can see this file in windows explorer.

Applets run through a browser, and therefore require an htm file. JCreator will create this for you, or you can create one manually.

New security on java apps has made browser testing difficult. JCreator features an applet viewer making testing easier.

Page 6: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Libraries A library is a collection of useful classes. Use the import statement to make a

library available to your program.

You will use several libraries in this course, such as java.awt and javax.swing.

Page 7: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Structure of a Java Program Java programs are made up of a number files

called classes, each one performing a specific task.

One class in the program will contain the main() method, which the computer searches for to get things running.

An applet will have a paint() method that is called automatically when it is started.

Inside of a class we have methods and instance variables.

Page 8: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Naming Conventions Classes are named in TitleCase Methods are named in camelCase and

always have () Variables are named in camelCase Constants (aka finals) are UPPER-CASE.

Page 9: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Java Help The best help for java is the java api on

the Internet.

Try Look up the drawString method api.

Page 10: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

• Close your workspace, and create a new Blank Workspace for Applications.

• Add a New Project named HelloWorld.• It will come up similar to below. Alter yours to match this

and make sure it compiles and runs.

Page 11: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

• Close your workspace, and create a new Blank Workspace for GUI-Apps.

• Add a New Project named HelloWorldGUI.• It will come up similar to below. Alter yours to match this

and make sure it compiles and runs.

Page 12: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

An Applet with Graphics Close your workspace and open the Applet workspace. Add a new applet project named ShapesAndColors.

The api can give you more information on possible graphics methods that you may use to create a unique image.

Page 13: Java The Beginning. Why Java?  Currently, this is the language of the international AP course which runs Feb-Apr  FREE!  Platform-independent  Simple

Work on Lab 01D – Robot. All required files are on the shared drive.