Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 University of Utah – School of Computing Computer Science 1021 "Applets and Applications"

Similar presentations


Presentation on theme: "1 University of Utah – School of Computing Computer Science 1021 "Applets and Applications""— Presentation transcript:

1 1 University of Utah – School of Computing Computer Science 1021 "Applets and Applications"

2 University of Utah – School of Computing University of Utah 2 Methods Every method must be called before it can do anything Two ways it can be called -By Java (automatically) -By the programmer (explicitly)

3 University of Utah – School of Computing University of Utah 3 Methods Automatically called methods -init() -paint() -actionPerformed()

4 University of Utah – School of Computing University of Utah 4 Methods Manually called methods -JPanel.add(button) // or whatever -Integer.parseInt() -Math.random() -JTextField.getText()

5 University of Utah – School of Computing University of Utah 5 Methods (show example on whiteboard)

6 University of Utah – School of Computing University of Utah 6 Applets: A Review Run inside a web browser Extend JApplet Don't control their own size

7 University of Utah – School of Computing University of Utah 7 Java Applications Run in their own window -(or no window at all!) Don't have to "extend" anything -(but most do, anyway) Can set their own window size!

8 University of Utah – School of Computing University of Utah 8 Application Example Eclipse!

9 University of Utah – School of Computing University of Utah 9 Application Example Homework 4 as an application -(show demo)

10 University of Utah – School of Computing University of Utah 10 10 A Recipe for Applets Extend JApplet Write init() and/or paint() method Tell Eclipse (or a web page) how big to make it

11 University of Utah – School of Computing University of Utah 11 11 A Recipe for Applications Extend JFrame to give us a window Write a main() method Tell application: -How big to make the window -To open the window -What to do when the window closes

12 University of Utah – School of Computing University of Utah 12 12 More on methods Applets told us what methods to write Applications don't, except main(). What to do? -Put all our code inside main()? -Make up our own brand new methods?

13 University of Utah – School of Computing University of Utah 13 13 More on methods We can write our own methods! Then it's up to us to call them. -Java won't call them automatically

14 University of Utah – School of Computing University of Utah 14 14 Show and Tell Let's look at a simple example together -(you'll get to do one yourself tomorrow)


Download ppt "1 University of Utah – School of Computing Computer Science 1021 "Applets and Applications""

Similar presentations


Ads by Google