Chapter 12 Applets and Advanced Graphics

 

1.         You run an applet from a Web browser or from the Applet Viewer utility. The applet must be embedded in an HTML file.

 

            2.         See the section "The Applet Class."

 

3.         The getParameter() method is defined in the Applet class.

 

4.               The components are added to the content pane of the applets.

 

5.         See the section "The <applet> HTML Tag." You use the <param> tag to pass parameters to an applet.

 

6.        An application has a main() method and runs as a standalone. An applet does not need a main method and must run from a Web browser. Applications and applets are compiled in the same way.

 

Applets are not allowed to read from, or write to, the file system of the computer. Applets are not allowed to run any programs on the browser's computer. Applets are not allowed to establish connections between the user's computer and another computer except with the server where the applets are stored.

 

7.         See the section "Creating Multiple Windows" in Chapter 10, "Creating User Interfaces." You can launch multiple frames from applications; similarly, you can launch frames from an applet.

 

8.         Yes. You can create an instance of JApplet and place it in a frame and use it.

 

9.         The event type for a mouse movement is MouseMotionEvent. The event type for getting key input is KeyEvent.

 

10.       The listener interface for move pressed, released, clicked, entered, and exited is MouseListener. The listener interface for mouse moved and dragged is MouseMotionListener.

 

11.       keyTyped(KeyEvent e), keyPressed(KeyEvent e), and keyReleased(KeyEvent e)

 

12.       mouseMoved(MouseEvent e) or mouseDragged(MouseEvent e)

 

13.       See the section "The CardLayout Manager."

 

14.       See the section "The GridBagLayout Manager."

 

15.       The order in which the components are added into a container is important for the FlowLayout, GridLayout, and CardLayout managers, but it is not important for BorderLayout and GridBagLayout.

 

16.       The FlowLayout manager.

 

17.       You can place the components without using a layout manager. The disadvantage of not using a layout manager is that it may look fine on one machine but become unusable on other machines.