All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.awt.ActiveLabel
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Label
|
+----jcsp.awt.ActiveLabel
- public class ActiveLabel
- extends Label
- implements CSProcess
Process Diagram
External View
_______________
configure | |
----->-----| ActiveLabel |
|_______________|
Internal View
________________
| ____________ |
configure | | | |
----->-------| Configure | |
| |____________| |
| |
| ActiveLabel |
|________________|
Description
An ActiveLabel is a sub class of Label which uses Channels for event
notification and configuration.
It is possible to register Channels to be used to notify the
occurrence of other types of Event that the Label generates. This can
be done by calling one of the addXXXXEventChannel() methods.
To configure the Label messages can be sent down the configure
channel. If the configure Channel is not a null reference a new Configure
is created. The configure process sits in an infinite loop which reads
from the configure Channel and configures the component based on the
Object received (see table below for details).
Channel Protocols
Input Channels |
configure |
String |
Change the label on the Label to the value of the String |
Boolean |
- If the Boolean Object refers to the Boolean.TRUE instance the
button is made active
- If the Boolean Object refers to the Boolean.FALSE instance the
button is made inactive
- If the Boolean Object refers to any other Boolean instance the
message is discarded
|
Output Channels |
|
|
|
Example
import java.awt.*;
import jcsp.lang.*;
import jcsp.awt.*;
public class LabelExample extends Frame {
public LabelExample() {
super("Label Example");
final Channel label = new One2OneChannel();
ActiveLabel b = new ActiveLabel(label, "Close");
add(b);
setVisible(true);
new Parallel(new CSProcess[] {
b,
new CSProcess() {
public void run() {
int value = 0;
while (value < 10) {
label.write("Value = " + value);
value++;
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
}
setVisible(false);
System.exit(0);
}
}
}).run();
}
public static void main(String argv[]) {
new LabelExample();
}
}
- Author:
- P.D.Austin
-
ActiveLabel()
- Constructs a ActiveLabel with no label and no configuration Channel.
-
ActiveLabel(Channel)
- Constructs a ActiveLabel with no label and the configuration Channel configure.
-
ActiveLabel(Channel, String)
- Constructs a ActiveLabel with the label s and the configuration Channel configure.
-
ActiveLabel(String)
- Constructs a ActiveLabel with the label s and no configuration Channel.
-
addComponentEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a ComponentEvent has occurred on the component.
-
addFocusEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a FocusEvent has occurred on the component.
-
addKeyEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a KeyEvent has occurred on the component.
-
addMouseEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a MouseEvent has occurred on the component.
-
addMouseMotionEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a MouseMotionEvent has occurred on the component.
-
run()
- The main body of this process.
ActiveLabel
public ActiveLabel()
- Constructs a ActiveLabel with no label and no configuration Channel.
ActiveLabel
public ActiveLabel(String s)
- Constructs a ActiveLabel with the label s and no configuration Channel.
- Parameters:
- s - The label displayed on the ActiveLabel
ActiveLabel
public ActiveLabel(Channel configure)
- Constructs a ActiveLabel with no label and the configuration Channel configure.
- Parameters:
- configure - The Channel configuration events should be sent down. Can be null if no configuration is required.
ActiveLabel
public ActiveLabel(Channel configure,
String s)
- Constructs a ActiveLabel with the label s and the configuration Channel configure.
- Parameters:
- configure - The Channel configuration events should be sent down. Can be null if no configuration is required.
- s - The label displayed on the ActiveLabel
addComponentEventChannel
public void addComponentEventChannel(ChannelOutput componentEvent)
- Add a new Channel to the Component which will be used to notify that
a ComponentEvent has occurred on the component. This should be used
instead of registering a ComponentListener with the component. It is
possible to add more than one Channel by calling this method multiple times
If the reference passed is null no action will be taken. Otherwise
a new ComponentEventHanlder will be generated for the Channel so that
each Channel operates independently of the others.
NOTE: This method must be called before this process is run otherwise
it will not function correctly.
- Parameters:
- componentEvent - The channel to send component events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- ComponentEventHandler
addFocusEventChannel
public void addFocusEventChannel(ChannelOutput focusEvent)
- Add a new Channel to the Component which will be used to notify that
a FocusEvent has occurred on the component. This should be used
instead of registering a FocusListener with the component. It is
possible to add more than one Channel by calling this method multiple times
If the reference passed is null no action will be taken. Otherwise
a new FocusEventHanlder will be generated for the Channel so that
each Channel operates independently of the others.
NOTE: This method must be called before this process is run otherwise
it will not function correctly.
- Parameters:
- focusEvent - The channel to send focus events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- FocusEventHandler
addKeyEventChannel
public void addKeyEventChannel(ChannelOutput keyEvent)
- Add a new Channel to the Component which will be used to notify that
a KeyEvent has occurred on the component. This should be used
instead of registering a KeyListener with the component. It is
possible to add more than one Channel by calling this method multiple times
If the reference passed is null no action will be taken. Otherwise
a new KeyEventHanlder will be generated for the Channel so that
each Channel operates independently of the others.
NOTE: This method must be called before this process is run otherwise
it will not function correctly.
- Parameters:
- keyEvent - The channel to send key events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- KeyEventHandler
addMouseEventChannel
public void addMouseEventChannel(ChannelOutput mouseEvent)
- Add a new Channel to the Component which will be used to notify that
a MouseEvent has occurred on the component. This should be used
instead of registering a MouseListener with the component. It is
possible to add more than one Channel by calling this method multiple times
If the reference passed is null no action will be taken. Otherwise
a new MouseEventHanlder will be generated for the Channel so that
each Channel operates independently of the others.
NOTE: This method must be called before this process is run otherwise
it will not function correctly.
- Parameters:
- mouseEvent - The channel to send key events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- MouseEventHandler
addMouseMotionEventChannel
public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent)
- Add a new Channel to the Component which will be used to notify that
a MouseMotionEvent has occurred on the component. This should be used
instead of registering a MouseMotionListener with the component. It is
possible to add more than one Channel by calling this method multiple times
If the reference passed is null no action will be taken. Otherwise
a new MouseMotionEventHanlder will be generated for the Channel so that
each Channel operates independently of the others.
NOTE: This method must be called before this process is run otherwise
it will not function correctly.
- Parameters:
- mouseMotionEvent - The channel to send key events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- MouseMotionEventHandler
run
public void run()
- The main body of this process.
All Packages Class Hierarchy This Package Previous Next Index