intro to java 2 by geb thomas based on the java tutorialjava tutorial
TRANSCRIPT
![Page 1: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/1.jpg)
Intro to Java 2
By Geb ThomasBased on the Java Tutorial
![Page 2: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/2.jpg)
What is Java?Platform independent codeRuns on many machinesRuns within browsers as appletsWill soon run on cell phones, microwaves, car displays and washing machines, for example.
![Page 3: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/3.jpg)
How do you make Java go?Create a java file (HelloWorldApp.java)Compile the java file with javac to make bytecodes (javac HelloWorldApp.java)
Creates HelloWorldApp.class
Run the bytecodes on a java virtual machine. (java HelloWorldApp)
![Page 4: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/4.jpg)
Where Do You Get This Stuff?
http://java.sun.com
![Page 5: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/5.jpg)
A Simple Example
/** The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */
class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); //Display the string. }}
![Page 6: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/6.jpg)
Objects
Objects are high level concepts that can have
Variables (data associated with the concept)Methods (actions associated with the concept)
![Page 7: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/7.jpg)
Passing Messages
![Page 8: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/8.jpg)
ClassesDefinition: A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.
![Page 9: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/9.jpg)
InheritanceSubclassSuperclassHierarchyInheritanceOverrideAbstract classes
![Page 10: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/10.jpg)
Putting the Ideas Into Action
ClickMe.java Spot.java <applet code="ClickMe.class" width="300" height="150"> </applet>
![Page 11: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/11.jpg)
First Swing Exampleimport javax.swing.*;
public class HelloWorldSwing { public static void main(String[] args) { JFrame frame = new JFrame("HelloWorldSwing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }
![Page 12: Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial](https://reader036.vdocument.in/reader036/viewer/2022082710/56649e7a5503460f94b7a3a9/html5/thumbnails/12.jpg)
Actions and Events
Examples of Events and Their Associated Event Listeners
Act that Results in the Event Listener Type
User clicks a button, presses Return while typing in a text field, or chooses a menu item
ActionListener
User closes a frame (main window) WindowListener User presses a mouse button while the cursor is over a component
MouseListener
User moves the mouse over a component MouseMotionListener Component becomes visible ComponentListener Component gets the keyboard focus FocusListener
Table or list selection changes ListSelectionListener