All Packages Class Hierarchy This Package Previous Next Index
Class framework.awt.FileField
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----framework.awt.FileField
- public class FileField
- extends Panel
A component that can be used to specify the name of a file. The user
can simply type a filename into a TextField, or he or she can select a
file using a FileDialog that can be activated by a pressing a button
in the FileField. FileField is a subclass of java.awt.Panel because
it consists of more than one component.
If an application wants to be notified when the filename in the
FileField changes (either by the user pressing return in the TextField
or by getting a new selection from the FileDialog), it should
implement the ActionListener interface and register the new listener
to receive events from the FileField, by calling the
addActionListener() method. The new filename is available to the
application through the action event's command.
The FileField can also be queried for the current filename using
method getFilename().
- Version:
- $Revision: 1.5 $
- See Also:
- ActionListener, getActionCommand, addActionListener, getFilename, TextField, FileDialog
-
actionListener
-
-
button
-
-
fileDialog
-
-
textField
-
-
FileField(Frame, String)
- Constructs a new FileField.
-
addActionListener(ActionListener)
- Adds the specified action listener to receive action events from this
FileField.
-
buttonActionPerformed(ActionEvent)
- This method is invoked by the FileField when the Button is pressed or
when the TextField sends an action event (when the user presses enter
in the TextField).
-
generateActionEvent(ActionEvent)
- Create a new ActionEvent to be sent to the ActionListeners of the
FileField.
-
getFilename()
- Get the filename that is represented by this FileField.
-
processActionEvent(ActionEvent)
-
Processes action events occurring on this TextField by dispatching
them to any registered ActionListener objects.
-
processEvent(AWTEvent)
- Processes events on this FileField.
-
removeActionListener(ActionListener)
- Removes the specified action listener so that it no longer receives
action events from this FileField.
-
setFilename(String)
- Set the filename represented by this FileField to be the specified
filename.
-
textFieldActionPerformed(ActionEvent)
- This method is invoked by the FileField when the TextField sends an
action event (when the user presses enter in the TextField).
textField
private TextField textField
button
private Button button
fileDialog
private FileDialog fileDialog
actionListener
private ActionListener actionListener
FileField
public FileField(Frame parent,
String initialFilename)
- Constructs a new FileField.
- Parameters:
- parent
- the owner of the FileField.
- initialFilename
- a String to display in the FileField. The preferred size of
the FileField is based on the length of this String.
addActionListener
public void addActionListener(ActionListener l)
- Adds the specified action listener to receive action events from this
FileField. Action events occur when the user selects a new filename.
- Parameters:
- l - the action listener
- See Also:
- ActionListener, removeActionListener
removeActionListener
public void removeActionListener(ActionListener l)
- Removes the specified action listener so that it no longer receives
action events from this FileField.
- Parameters:
- l - the action listener
- See Also:
- ActionListener, addActionListener
getFilename
public String getFilename()
- Get the filename that is represented by this FileField. The returned
name is the complete text as entered in the TextField or selected by
the FileDialog. It can contain an optional directory name.
- See Also:
- setFilename
setFilename
public void setFilename(String filename)
- Set the filename represented by this FileField to be the specified
filename.
- Parameters:
- filename - the new filename.
- See Also:
- getFilename
processEvent
protected void processEvent(AWTEvent e)
- Processes events on this FileField. If the event is an ActionEvent, it
invokes the processActionEvent method, else it invokes its
superclass's processEvent.
- Parameters:
- e - the event.
- Overrides:
- processEvent in class Container
processActionEvent
protected void processActionEvent(ActionEvent e)
- Processes action events occurring on this TextField by dispatching
them to any registered ActionListener objects. NOTE: This method will
not be called unless action events are enabled for this component;
this happens when one of the following occurs: a) An ActionListener
object is registered via addActionListener() b) Action events are
enabled via enableEvents()
- Parameters:
- e - the action event
- See Also:
- enableEvents
generateActionEvent
private ActionEvent generateActionEvent(ActionEvent e)
- Create a new ActionEvent to be sent to the ActionListeners of the
FileField. The most parts of the new ActionEvent are copied from a
specified existing ActionEvent. Only the command and the source
explicitly set by this method.
- Parameters:
- e - the ActionEvent to model the new ActionEvent after.
- Returns:
- a new ActionEvent.
textFieldActionPerformed
private void textFieldActionPerformed(ActionEvent e)
- This method is invoked by the FileField when the TextField sends an
action event (when the user presses enter in the TextField). A new
ActionEvent is created and sent to the ActionListeners of the
FileField using method processEvent().
- See Also:
- processEvent
buttonActionPerformed
private void buttonActionPerformed(ActionEvent e)
- This method is invoked by the FileField when the Button is pressed or
when the TextField sends an action event (when the user presses enter
in the TextField). It shows the FileDialog to ask the user for a
filename and sets the text of the TextField to the name selected with
the FileDialog. The FileDialog's directory and filename are preset
using the existing filename in the TextField. If the FileDialog was
not cancelled a new ActionEvent is created and sent to the
ActionListeners of the FileField using method processEvent().
- See Also:
- processEvent
All Packages Class Hierarchy This Package Previous Next Index