All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.awt.ActiveFileDialog
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Window
|
+----java.awt.Dialog
|
+----java.awt.FileDialog
|
+----jcsp.awt.ActiveFileDialog
- public class ActiveFileDialog
- extends FileDialog
- implements CSProcess
Process Diagram
External View
__________________
configure | | event
----->-----| ActiveFileDialog |--->---
|__________________|
Internal View
__________________________________________
| ____________ ____________________ |
configure | | | | | | event
----->-------| Configure | | WindowEventHandler |----->---
| |____________| |____________________| |
| |
| ActiveFileDialog |
|__________________________________________|
Description
An ActiveFileDialog is a sub class of FileDialog which uses Channels for event
notification and configuration.
If the event Channel is not a null reference an new WindowEventHandler is
created with the Channel and is registered as WindowListener with the
ActiveFileDialog and has its windowOpened(), windowClosed(), windowClosing(),
windowIconified(), windowDeiconified(), windowActivated() or windowDeactivated()
methods invoked when WindowEvents are generated. Any events generated
when the WindowEventHandler is blocked writing to the event Channel are
ignored so that the main Java Event Thread is not blocked. The output
from the WindowEventHanlder is connected to the event Channel causing an
Object to be sent down the Channel when the WindowEvents occur.
It is also possible to register Channels to be used to notify the
occurrence of other types of Event that the FileDialog generates. This can
be done by calling one of the addXXXXEventChannel() methods.
To configure the FileDialog 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 |
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 |
event |
WindowEvent |
The WindowEvent Object generated by the component |
Example
import java.awt.*;
import jcsp.lang.*;
import jcsp.awt.*;
public class FileDialogExample {
public FileDialogExample() {
final Channel event = new One2OneChannel();
final Channel id = new One2OneChannel();
ActiveFileDialog w = new ActiveFileDialog(null, event, "FileDialog Example");
w.setVisible(true);
new Parallel(new CSProcess[] {
w,
new EventIDFilter(event, id),
new CSProcess() {
public void run() {
Integer i = (Integer)id.read();
if (i.intValue() == WindowEvent.WINDOW_OPENED) {
setVisible(false);
w.setVisible(false);
System.exit(0);
}
}
}
}).run();
}
public static void main(String argv[]) {
new FileDialogExample();
}
}
- Author:
- P.D.Austin
-
par
- The Parallel construct containing the processes to be executed by this CSProcess.
-
ActiveFileDialog(ChannelInput, ChannelOutput, Frame)
- Creates a file dialog for loading a file.
-
ActiveFileDialog(ChannelInput, ChannelOutput, Frame, String)
- Creates a file dialog window with the specified title for loading
a file.
-
ActiveFileDialog(ChannelInput, ChannelOutput, Frame, String, int)
- Creates a file dialog window with the specified title for loading
or saving a file.
-
ActiveFileDialog(Frame)
- Creates a file dialog for loading a file.
-
ActiveFileDialog(Frame, String)
- Creates a file dialog window with the specified title for loading
a file.
-
ActiveFileDialog(Frame, String, int)
- Creates a file dialog window with the specified title for loading
or saving a file.
-
addComponentEventChannel(ChannelOutput)
- Add a new Channel to the Component which will be used to notify that
a ComponentEvent has occurred on the component.
-
addContainerEventChannel(ChannelOutput)
- Add a new Channel to the Container which will be used to notify that
a ContainerEvent has occurred on the Container.
-
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.
par
protected Parallel par
- The Parallel construct containing the processes to be executed by this CSProcess.
ActiveFileDialog
public ActiveFileDialog(Frame parent)
- Creates a file dialog for loading a file. The title of the
file dialog is initially empty.
- Parameters:
- parent - the owner of the dialog
ActiveFileDialog
public ActiveFileDialog(Frame parent,
String title)
- Creates a file dialog window with the specified title for loading
a file. The files shown are those in the current directory.
- Parameters:
- parent - the owner of the dialog.
- title - the title of the dialog.
ActiveFileDialog
public ActiveFileDialog(Frame parent,
String title,
int mode)
- Creates a file dialog window with the specified title for loading
or saving a file.
If the value of mode
is LOAD
, then the
file dialog is finding a file to read. If the value of
mode
is SAVE
, the file dialog is finding
a place to write a file.
- Parameters:
- parent - the owner of the dialog.
- title - the title of the dialog.
- mode - the mode of the dialog.
ActiveFileDialog
public ActiveFileDialog(ChannelInput configure,
ChannelOutput event,
Frame parent)
- Creates a file dialog for loading a file. The title of the
file dialog is initially empty.
- Parameters:
- configure - The Channel configuration events should be sent down. Can be null if no configuration is required.
- event - The Channel events will be notified down when the button is pressed. Can be null if events are going to be ignored.
- parent - the owner of the dialog
ActiveFileDialog
public ActiveFileDialog(ChannelInput configure,
ChannelOutput event,
Frame parent,
String title)
- Creates a file dialog window with the specified title for loading
a file. The files shown are those in the current directory.
- Parameters:
- configure - The Channel configuration events should be sent down. Can be null if no configuration is required.
- event - The Channel events will be notified down when the button is pressed. Can be null if events are going to be ignored.
- parent - the owner of the dialog.
- title - the title of the dialog.
ActiveFileDialog
public ActiveFileDialog(ChannelInput configure,
ChannelOutput event,
Frame parent,
String title,
int mode)
- Creates a file dialog window with the specified title for loading
or saving a file.
If the value of mode
is LOAD
, then the
file dialog is finding a file to read. If the value of
mode
is SAVE
, the file dialog is finding
a place to write a file.
- Parameters:
- configure - The Channel configuration events should be sent down. Can be null if no configuration is required.
- event - The Channel events will be notified down when the button is pressed. Can be null if events are going to be ignored.
- parent - the owner of the dialog.
- title - the title of the dialog.
- mode - the mode of the dialog.
addContainerEventChannel
public void addContainerEventChannel(ChannelOutput containerEvent)
- Add a new Channel to the Container which will be used to notify that
a ContainerEvent has occurred on the Container. This should be used
instead of registering a ContainerListener with the Container. 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 ContainerEventHanlder 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:
- containerEvent - The channel to send Container events down. If the Channel
is to be shared with other events it should be a Many2OneChannel.
- See Also:
- ContainerEventHandler
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