All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.objectplanet.NewsTicker

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

public class NewsTicker
extends Applet
implements Runnable
The news ticker applet displays a list of news scrolling vertically, with the ability to scroll up and down interactivly and click on a link to open a page with more news.

<applet code=com.objectplanet.NewsTicker
archive=com.objectplanet.NewsTicker.jar
width=200 height=400>
<param name=header value="News">
<param name=newsURL value="news.xml">
</applet>

The URL containing the news should contain news in the following format:

<news>
  <header>
    news header text
  </header>
  <body>
    This is the text of the news item
    body. It can contain as much text
    as you want. The item in the link
    tag is the url opened when the
    user clicks on the news body.
  </body>
  <link>
    newsitem.html
  </link>
</news>

newsURL
The URL where the news are read from. The news needs to be in XML format as displayed above. Use \n for multiline labels.
<param name=newsURL value="news.xml">

header
The news ticker applet header. This header is always visible and does not scroll. The header can also be empty. Use \n for multiline labels.
<param name=header value="this is a\nmultiline header">

headerFont
The font used for the applet header. The first field is the font name, the second is plain, bold, or bolditalic. The last field is the point size of the font.
<param name=headerFont value="Arial,bold,16">

headerColor
The color used for the applet header. The color can be set using one of the following color names; black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, or you can use the URL hex code for the color.
<param name=headerColor value="red">
<param name=headerFont value="#c0c0c0">

headerAlignment
The horizontal alignment of the applet header.
<param name=headerAlignment value="left">
<param name=headerAlignment value="center">
<param name=headerAlignment value="right">

newsHeaderFont
Each news item has a header. This is the font used for the header.
<param name=newsHeaderFont value="Arial,bold,11">

newsHeaderColor
The color used for the news item header.
<param name=newsHeaderColor value="blue">

newsFont
The font used for the news item body.
<param name=newsFont value="Arial,plain,11">

newsColor
The color used for the news item body.
<param name=newsColor value="gray">

focusColor
The color used for the news item body when the user places the mouse button over it.
<param name=focusColor value="red">

target
The default window to open the url is the same window as the applet is in. Use this parameter to control which window the url is openened in. See here for target details.
<param name=target value="window_name">

background
The background color of the applet.
<param name=background value="orange">

scrollSpeed
The speed of the scrolling. The scrolling can be set with a value from 0 (no scrolling) through 100 (fast scrolling).
<param name=scrollSpeed value="60">

border
You can display a border around the applet and applet header. Control the color of the border by seperating the border type and color with a comma.
<param name=border value="none">
<param name=border value="solid">
<param name=border value="up">
<param name=border value="down">
<param name=border value="grooved">
<param name=border value="embossed">
<param name=border value="embossed,orange">
<param name=border value="grooved,#c0aaff">

wrapSpace
By default, the first news item starts again at the bottom when the last has left the top of the applet. Set this parameter to control the space between the last item and where the first one starts again. Use -1 for the default behavior.
<param name=wrapSpace value="100">

newsXMLTag
You can control the xml tag used for each news item. The default tag is <news>. Specify the xml tag without the enclosing < and >.
<param name=newsXMLTag value="news_item">

newsHeaderXMLTag
You can control the xml tag used for the news header. The default tag is <header>. Specify the xml tag without the enclosing < and >.
<param name=newsHeaderXMLTag value="news_header">

newsBodyXMLTag
You can control the xml tag used for the news body. The default tag is <body>. Specify the xml tag without the enclosing < and >.
<param name=newsBodyXMLTag value="news_body">

newsLinkXMLTag
You can control the xml tag used for the news link. The default tag is <link>. Specify the xml tag without the enclosing < and >.
<param name=newsLinkXMLTag value="news_link">

Author:
Bjorn J. Kvande

Constructor Index

 o NewsTicker()
Constructs the news ticker.

Method Index

 o handleEvent(Event)
Processes the mouse events.
 o init()
Initializes the news ticker, reading the news parameters.
 o paint(Graphics)
Renders the news ticker.
 o run()
Thread that scrolls the news.
 o setParameter(String, String)
Sets a parameter.
 o start()
Starts the news ticker scroller.
 o stop()
Stops the news ticker scroller.
 o update(Graphics)
Overridden to avoid flickering.

Constructors

 o NewsTicker
 public NewsTicker()
Constructs the news ticker.

Methods

 o init
 public void init()
Initializes the news ticker, reading the news parameters.

Overrides:
init in class Applet
 o start
 public void start()
Starts the news ticker scroller.

Overrides:
start in class Applet
 o stop
 public void stop()
Stops the news ticker scroller.

Overrides:
stop in class Applet
 o setParameter
 public void setParameter(String name,
                          String value)
Sets a parameter.

Parameters:
name - The name of the parameter.
value - The value of the parameter to set.
 o update
 public void update(Graphics g)
Overridden to avoid flickering.

Overrides:
update in class Container
 o paint
 public void paint(Graphics g)
Renders the news ticker.

Parameters:
g - The graphics object used to paint with.
Overrides:
paint in class Container
 o handleEvent
 public boolean handleEvent(Event event)
Processes the mouse events.

Overrides:
handleEvent in class Component
 o run
 public void run()
Thread that scrolls the news. Do not call directly.


All Packages  Class Hierarchy  This Package  Previous  Next  Index