applications and applets
play

Applications and Applets An applet is a program delivered via the - PowerPoint PPT Presentation

Applications and Applets An applet is a program delivered via the web security issues, sandbox model where does code/images/etc come from? How is it delivered? what browsers support the 1.1 AWT event model (what about 1.2)? Use


  1. Applications and Applets ● An applet is a program delivered via the web ➤ security issues, sandbox model ➤ where does code/images/etc come from? How is it delivered? ➤ what browsers support the 1.1 AWT event model (what about 1.2)? ● Use IE 4, Netscape 4 (patched), appletviewer to run an applet, appletviewer is good for debugging ● Possible to wrap up lots of classes in a .jar file ➤ java archive, similar to a tar file, possible to include .class files, .au, .gif, etc, so all code transferred at once 19. 1 Duke CPS 108

  2. Running an Applet ● An applet has an init() method ➤ similar to constructor, called only once, when the applet is first loaded ● An applet has a start() method ➤ called each time the applet becomes “active”, run the first time, or revisited e.g., via the back button in a browser ● An applet has a stop() method ➤ called when applet is invisible, e.g., user scrolls or goes to another web page ● other methods in an applet ➤ destroy, getAppletInfo, getParameterInfo ● Applet subclasses Panel, so it is an Container/Component 19. 2 Duke CPS 108

  3. Thread ● Threads are “lightweight” processes ➤ have access to same memory as other threads in the main process ➤ each thread runs as a separate control, on a multiprocessor these could be running simultaneously ➤ threads should each get a “time-slice” to run fairly ● Threads are created by subclassing Thread or implementing Runnable ➤ Threads have a run method, this is where the action is, but run is not called directly, only via Thread.start() ● Must be careful when many threads access the same object, synchronization is needed 19. 3 Duke CPS 108

Recommend


More recommend