1 Mouse Events See Figure 11 27 See

  • Slides: 11
Download presentation
1 Mouse Events • See Figure 11. 27 • See Example in Figure 11.

1 Mouse Events • See Figure 11. 27 • See Example in Figure 11. 28, 11. 31

1 Digital Images • Images are comprised of a two dimensional grid of pixels

1 Digital Images • Images are comprised of a two dimensional grid of pixels • Each pixel (picture element) contains information about a color • Many formats exist for storing images – Each has its own features – Examples: • JPEG • GIF • PNG

1 Images in Java • See Figure 21. 1

1 Images in Java • See Figure 21. 1

1 Concurrency in Java • Concurrency normally available in OS primitives – Most computers

1 Concurrency in Java • Concurrency normally available in OS primitives – Most computers today allow more than one process or task running at any given time – Computers with more than one processor can actually run more than one process at a time • Java provides built-in multithreading – Threads are to processes as applet are to applications – Multithreading improves the performance of some programs

1 Threads • Thread states – Born state • Thread was just created –

1 Threads • Thread states – Born state • Thread was just created – Ready state • Thread’s start method invoked • Thread can now execute – Running state • Thread is assigned a processor and running – Dead state • Thread has completed or exited • Eventually disposed of by system

1 A Thread's Life

1 A Thread's Life

1 Thread Priorities and Thread Scheduling • Java thread priority – Priority in range

1 Thread Priorities and Thread Scheduling • Java thread priority – Priority in range 1 -10 • Timeslicing – Each thread assigned time on the processor • called a quantum – Keeps highest priority threads running

1 Thread priority scheduling example

1 Thread priority scheduling example

1 Creating and Executing Threads • Sleep state – Thread method sleep called –

1 Creating and Executing Threads • Sleep state – Thread method sleep called – Thread sleeps for a set time interval then awakens • Example – Figure 16. 3: Thread. Tester. java

1 Animating a Series of Images • Threads are very useful for animation –

1 Animating a Series of Images • Threads are very useful for animation – Repeat • • Draw graphics Sleep Wake up Update – Loop structure handled at the thread level • Example – Figure 21. 2: Logo. Animator. java

1 Vectors • Class java. util. Vector – Array-like data structures that can resize

1 Vectors • Class java. util. Vector – Array-like data structures that can resize themselves dynamically – Contains a capacity – Grows by capacity increment if it requires additional space • Example – Figure 21. 1: Vector. Test. java