Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Applets

 

Ø You get access to 243 methods when you use JApplet.  The J prefix means it is in javax.

 

Ø Some of the methods in JApplet are defined in the JApplet class.

 

Ø The rest are through inheritance from the following classes as described below: Object, Component, Panel, Container, and Applet.

 

Ø 2 frequently used methods are init and paint. These (and some others take the place of the main method used in applications.

 

 

Applet Hierarchy

JApplet Methods

Japplet Methods from awt.Applet

JApplet Methods from awt.Component

JApplet Methods from lang.Object

Examples

JApplet Methods from awt.Container

JApplet Methods from awt.Panel

Exercises

 

Applet Hierarchy

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |

                                   +----com.sun.java.swing.JApplet


Applet Methods (22)
 

 

Source

Method

Description

AppletContext

getAppletContext()
 

Determines this applet's context, which allows the applet to query and affect the environment in which it runs.

java.lang.String

getAppletInfo()

Returns information about this applet.

AudioClip

getAudioClip(java.net.URL url)

Returns the AudioClip object specified by the URL argument.

AudioClip

getAudioClip(java.net.URL url, java.lang.String name)

Returns the AudioClip object specified by the URL and name arguments.

java.net.URL

getcodeBase()

Gets the base URL.

java.net.URL

getDocumentBase()

Gets the document URL.

java.awt.Image

getImage(java.net.URL url)

Returns an Image object that can then be painted on the screen.

java.awt.Image

getImage(java.net.URL url, java.lang.String name)

Returns an Image object that can then be painted on the screen.

java.util.Locale

getLocale()

Gets the Locale for the applet, if it has been set.

java.lang.String

getParameter(java.lang.String name)

Returns the value of the named parameter in the HTML tag.

java.lang.String[][]

getParameterInfo()

Returns information about the parameters than are understood by this applet.

void

init()

Called by the browser or applet viewer to inform this applet that it has been loaded into the system.

boolean

isActive()

Determines if this applet is active.

static AudioClip

newAudioClip(java.net.URL url)

Get an audio clip from the given URL

void

play(java.net.URL url)

Plays the audio clip at the specified absolute URL.

void

play(java.net.URL url, java.lang.String name)

Plays the audio clip given the URL and a specifier that is relative to it.

void

resize(java.awt.Dimension d)

Requests that this applet be resized.

void

resize(int width, int height)

Requests that this applet be resized.

void

setStub(AppletStub stub)

Sets this applet's stub.

void

showStatus(java.lang.String msg)

Requests that the argument string be displayed in the "status window".

void

start()

Called by the browser or applet viewer to inform this applet that it should start its execution.

 void

stop()

Called by the browser or applet viewer to inform this applet that it should stop its execution.

 
Method inherited from java.awt.Panel (1)
 
AddNotify

 

Methods inherited from java.awt.Container (51)

 
add, add, add, add, add, addContainerListener, addImpl

 

countComponents

 

deliverEvent, doLayout

 

findComponentAt, findComponentAt

 

getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt
 
getComponentCount, getComponents, getInsets, getLayout, getMaximumSize
getMinimumSize, getPreferredSize

 

insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint
 
paintComponents, paramString, preferredSize, print, printComponents

 

processContainerEvent, processEvent, remove, remove, removeAll

 

removeContainerListener, removeNotify, setCursor, setFont, setLayout
 
update, validate, validateTree

 

Methods inherited from java.awt.Component (129)

 
action, add, addComponentListener, addFocusListener, addInputMethodListener,   
addKeyListener, addMouseListener, addMouseMotionListener,addPropertyChangeListener, addPropertyChangeListener

 

bounds

 

checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage

 

disable, disableEvents, dispatchEvent

 

enable, enable, enableEvents, enableInputMethods

 

firePropertyChange

 

getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus

 

handleEvent, hasFocus, hide

 

imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible

 

keyDown, keyUp

 

list, list, list, location, lostFocus

 

mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move
nextFocus

 

paint, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent

 

remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint
repaint, repaint, requestFocus, reshape

 

setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize
setSize, setVisible, show, show, size

 

toString, transferFocus

 

Methods inherited from java.lang.Object (10)

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

JApplet Methods (20)

 o addImpl(Component, Object, int)
 o addNotify()
 o createRootPane()
Called by the constructor methods to create the default rootPane.
 o getAccessibleContext()
Get the AccessibleContext associated with this JApplet
 o getContentPane()
Returns the contentPane object for this applet.
 o getGlassPane()
Returns the glassPane object for this applet.
 o getJMenuBar()
Returns the menubar set on this applet.
 o getLayeredPane()
Returns the layeredPane object for this applet.
 o getRootPane()
Returns the rootPane object for this applet.
 o isRootPaneCHeckingEnabled()
 o processKeyEvent(KeyEvent)
 o removeNotify()
 o setContentPane(Container)
Sets the contentPane property.
 o setGlassPane(Component)
Sets the glassPane property.
 o setJMenuBar(JMenuBar)
Sets the menubar for this applet.
 o setLayeredPane(JLayeredPane)
Sets the layeredPane property.
 o setLayout(LayoutManager)
By default the layout of this component may not be set, the layout of its contentPane should be set instead.
 o setRootPane(JRootPane)
Sets the rootPane property.
 o setRootPaneCheckingEnabled(boolean)
If true then calls to add() and setLayout() will cause an exception to be thrown.
 o update(Graphics)

Calls paint (g).

TOTAL METHODS: 22 + 1 + 51 + 129 + 10 + 20 = 243