Oracle Forms 9i Samples and Demos


oracle.forms.demos.beans
Class TickerApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--oracle.ewt.lwAWT.LWComponent
                    |
                    +--oracle.forms.demos.beans.TickerApplet
All Implemented Interfaces:
javax.accessibility.Accessible, oracle.ewt.lwAWT.DoubleBufferer, oracle.ewt.help.HelpCapable, java.awt.image.ImageObserver, oracle.ewt.lwAWT.ImmediatePainter, oracle.ewt.lwAWT.KeyProcessor, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable, oracle.ewt.lwAWT.VirtualComponent

public class TickerApplet
extends oracle.ewt.lwAWT.LWComponent
implements java.lang.Runnable

Oracle Forms Server 9i JavaBean Example

This JavaBean provides displays a digital clock which shows the current time on the client computer. The digital clock can be set to display in all the standard Java colors and fonts. In addition to displaying the time, this JavaBean also is able to responds to the user dragging the mouse (moving the mouse over the component with a mouse button depressed). When the user performs this action, this component will move the time display to follow the mouse cursor.

Version:
1.0
Author:
sbutton 03/17/00
See Also:
Serialized Form

Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class oracle.ewt.lwAWT.LWComponent
DEFAULT_BORDERPAINTER, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_PAINTER, MNEMONIC_CHAR_NONE, MNEMONIC_INDEX_NONE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TickerApplet()
          The constructor for this JavaBean.
 
Method Summary
 void calcOffsets()
          Calculates the offsets to use when the string is displayed.
 java.awt.Color getBackground()
          Gets the background color currently being used
 java.awt.Font getFont()
          Gets the Font currently being used
 int getFontSize()
           
 java.awt.Color getForeground()
          Gets the foreground color currently being used
 java.lang.String getTimeString()
          Obtains the current time in a nice format using the DateFormat class.
 int getX()
          Gets the X offset being used
 int getY()
          Gets the Y offset being used
 void initMouseDrag()
          This methods sets up the component to be able to respond to the user mouse drag events.
 void paint(java.awt.Graphics g)
          Paint the component using the current attributes of the colors, fonts and string to be displayed
 void run()
          The guts of the component.
 void setBackground(java.awt.Color background)
          Sets the background color to use
 void setFont(java.awt.Font f)
          Sets the Font to use
 void setFontSize(int fs)
          Sets the Font size to use
 void setForeground(java.awt.Color foreground)
          Sets the foreground color to use
 void setSize(java.awt.Dimension dim)
          Set the size of the component, overriden from the super class so that the calcOffsets method can be called to work out the size of the component and where the string needs to be placed.
 void setX(int x)
          Sets the X offset for the display string
 void setY(int y)
          Sets the Y offset for the display string
 void start()
          Start the components actions by initialising the thread and setting it free
 void stop()
          Stop the component's actions by killing the thread and setting it back to null for future use.
 
Methods inherited from class oracle.ewt.lwAWT.LWComponent
accessAccessibleContext, addAnyEventListener, addImpl, addNotify, addPostKeyListener, addPreKeyListener, clipToParents, contains, convertInnerToOuterSize, convertInteriorToOuter, convertOuterToInterior, createAccessibleContext, disable, doLayout, enable, eventMatchesMnemonic, eventMatchesMnemonic, freezeRepaints, getAccessibleContext, getActualAlignment, getActualReadingDirection, getAlignment, getBaseClassName, getBorderContext, getBorderInsets, getBorderPainter, getClientProperty, getColorScheme, getDefaultHelpProvider, getDefaultName, getDocumentSize, getDoubleBuffer, getEWTDropTarget, getFill, getFocusedComponent, getGraphics, getHelpBook, getHelpProvider, getHelpTopic, getInnerBounds, getInnerHeight, getInnerOrigin, getInnerSize, getInnerWidth, getInsets, getInteriorAlignmentX, getInteriorAlignmentY, getInvalidateFlags, getLookAndFeel, getMnemonicChar, getMnemonicIndex, getMnemonicString, getName, getPageBounds, getPaintContext, getPaintData, getPaintState, getPrintPaintContext, getReadingDirection, getRepaintFlags, getToolTipValue, getUI, getUIClassID, getUIDefaults, hasFocus, hasGlobalFocus, hasMnemonicModifier, hasWindowFocus, hide, imageUpdate, insets, interiorContains, invalidate, invalidateAndRepaintIfNecessary, isActive, isBorderTransparent, isChildClipped, isClippedBySibling, isFocusTraversable, isInteriorTransparent, isLocaleDefaulted, isPaintPropagationRequired, isReadingDirectionDefaulted, isTransparent, paintAll, paintImmediate, paintImmediate, paintImmediateInterior, paintImmediateInterior, paintImmediateUnclipped, paintInterior, paintOverChildren, paramString, pointInInterior, pointIsInChild, postProcessKey, print, printAll, printPage, processEvent, processEventImpl, processFocusEvent, processMouseEvent, putClientProperty, redispatchEvent, remove, removeAll, removeAnyEventListener, removeClientProperty, removeNotify, removePostKeyListener, removePreKeyListener, repaint, repaintInterior, repaintInterior, reshape, setAlignment, setColorScheme, setDefaultHelpProvider, setEnabled, setEWTDropTarget, setFill, setHelpBook, setHelpProvider, setHelpTopic, setLocale, setLookAndFeel, setMnemonicChar, setMnemonicIndex, setReadingDirection, setToolTipValue, setToolTipValue, setUI, setVisible, shiftFrozenDamage, showHelp, unfreezeRepaints, update, updateAlignment, updateLocale, updateReadingDirection, updateUI, updateUI, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, gotFocus, handleEvent, inside, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.ewt.lwAWT.VirtualComponent
getBounds, getSize
 

Constructor Detail

TickerApplet

public TickerApplet()
The constructor for this JavaBean. Initialises the mousedrag opereration
Method Detail

setFontSize

public void setFontSize(int fs)
Sets the Font size to use
Parameters:
the - size of the font to display

getFontSize

public int getFontSize()

setFont

public void setFont(java.awt.Font f)
Sets the Font to use
Overrides:
setFont in class oracle.ewt.lwAWT.LWComponent
Parameters:
the - font to display

getFont

public java.awt.Font getFont()
Gets the Font currently being used
Overrides:
getFont in class oracle.ewt.lwAWT.LWComponent
Returns:
the font being displayed

setBackground

public void setBackground(java.awt.Color background)
Sets the background color to use
Overrides:
setBackground in class oracle.ewt.lwAWT.LWComponent
Parameters:
the - background color to use

getBackground

public java.awt.Color getBackground()
Gets the background color currently being used
Overrides:
getBackground in class oracle.ewt.lwAWT.LWComponent
Returns:
the background color being displayed

setForeground

public void setForeground(java.awt.Color foreground)
Sets the foreground color to use
Overrides:
setForeground in class oracle.ewt.lwAWT.LWComponent
Parameters:
the - foreground color to use

getForeground

public java.awt.Color getForeground()
Gets the foreground color currently being used
Overrides:
getForeground in class oracle.ewt.lwAWT.LWComponent
Returns:
the background color being displayed

setX

public void setX(int x)
Sets the X offset for the display string
Parameters:
the - X offset

getX

public int getX()
Gets the X offset being used
Overrides:
getX in class java.awt.Component
Returns:
the X offset

setY

public void setY(int y)
Sets the Y offset for the display string
Parameters:
the - Y offset

getY

public int getY()
Gets the Y offset being used
Overrides:
getY in class java.awt.Component
Returns:
the Y offset

setSize

public void setSize(java.awt.Dimension dim)
Set the size of the component, overriden from the super class so that the calcOffsets method can be called to work out the size of the component and where the string needs to be placed.
Overrides:
setSize in class java.awt.Component
Parameters:
the - desired size of the component

getTimeString

public java.lang.String getTimeString()
Obtains the current time in a nice format using the DateFormat class. Will return a timestring of HH:MM:SS
Returns:
the current time in HH:MM:SS format

calcOffsets

public void calcOffsets()
Calculates the offsets to use when the string is displayed. This is used to center the string when it is first displayed and is only called once. If the user performs a mouse-drag then the values set by the method will be overriden and the string will no longer be centered.

start

public void start()
Start the components actions by initialising the thread and setting it free

stop

public void stop()
Stop the component's actions by killing the thread and setting it back to null for future use.

paint

public void paint(java.awt.Graphics g)
Paint the component using the current attributes of the colors, fonts and string to be displayed
Overrides:
paint in class oracle.ewt.lwAWT.LWComponent
Parameters:
the - graphics context to draw on

run

public void run()
The guts of the component. This is where the actions are performed to actually have the component perform actions on the screen. Creates the double buffer graphics context and images, obtains the time and then gets it painted. Goes to sleep for 1000ms which should see it only repaint the display every second.
Specified by:
run in interface java.lang.Runnable

initMouseDrag

public void initMouseDrag()

This methods sets up the component to be able to respond to the user mouse drag events. This method is called once and a mousedrag listener is registered with the component. When the user drags the mouse over this component, the listener will be notified.

The mousedrag listener is subclasses of the mouse motion adapter and the mousedragged method is overridden. The mousedragged method obtains the current [X,Y] position of the mouse and modifies the [X,Y] location being used to display the string to reflect this.


Oracle Forms 9i Samples and Demos