|
|
|
|
More Constructs : Hyperlinks
|
|
Step by Step
Import the usual figue packages.
|
import figue.*;
import figue.box.*;
import figue.path.*;
import figue.resource.* |
Import the event package.
Define an hyperlink history.
|
_history = new HyperlinkHistoryInterface() {
public final void clear() {
_followedLinks.clear();
}
public final boolean isVisited(Hyperlink aLink) {
return _followedLinks.containsKey(
(String)(aLink.getInfo()));
}
public final void setVisited(Hyperlink aLink) {
_followedLinks.put((String)(aLink.getInfo()),this);
}
private Hashtable _followedLinks = new Hashtable();
}; |
Add a listener to the facade.
|
_facade.addHyperlinkListener(new HyperlinkListenerInterface() {
public void linkEntered(HyperlinkEvent anEvent) {
...
}
public final void linkClicked(HyperlinkEvent anEvent) {
...
}
public final void linkExited(HyperlinkEvent anEvent) {
...
}
}); |
Check the events and update the history.
|
public final void linkClicked(HyperlinkEvent anEvent) {
try {
final String theString
= (String)(anEvent.getHyperlink().getInfo());
final URL theUrl;
if ( theString.equals(POSTER) ) {
theUrl = new URL("http://www.....");
}
else {
...
}
if ( theUrl!= null ) {
anEvent.getHyperlink().setVisited();
getAppletContext().showDocument(theUrl); |
Create a link with some information chunk.
|
theLink = new Hyperlink(URL,_history); |
Push some atoms in the link.
|
theLink.addChild(Atom.newAtom("its"));
theLink.addChild(Atom.newAtom('a'));
theLink.addChild(Atom.newAtom("wonderful"));
theLink.addChild(Atom.newAtom("life"));
theParagraph.addChild(theLink); |
|
|
Example
- Accelerators :
- home, end, page up, page down, left arrow,right arrow, up arrow, down arrow.
- Autoscrolling :
- drag the mouse inside the
text area, approach a border or a corner, and wait.
- Actions :
-
- - move the mouse over an underlined link,
- - click an underlined link,
- - reset the link history with the clear button.
|
|
|
Related Classes
and Methods
|
|
|
What Next ?
Now you can :
|
|
|
|
|
|
|
|
|