John W. Campbell
This class provides a command line input (single line) e.g. for JdlCellWindow.
Class, fields, constructor and methods:
Class Details
Accessible Fields
Constructor
Class Methods
Operational Methods
Resource Methods
Standard Positioning and Sizing
Add/Remove Action Listener
Overriden Superclass Methods
- Package:
- Jdl.JdlView;
- Class name:
- JdlCommandLine
- Class definition:
- public class JdlCommandLine
- Extends:
- JdlFramedPanel
- Implements:
- FocusListener
MouseListener
MouseMotionListener
KeyListener
ActionListener
- Actions:
- An action event will be generated when a command has been entered. The
associated object is the string entered. There is an option to generate action
events when the keyboard focus is lost or gained and the associated strings are
"<<focusLost>>" and "<<focusGained>>".
The following accessible fields have been defined:
- public final static int FREE
- Location Constraint: free.
- static final long serialVersionUID
A single constructor is available.
Constructor:
Standard constructor
Constructs a command with the required resources.
- Constructor Definition:
- public JdlCommandLine(int text_height, int text_width, Font prompt_font, Color prompt_colr, Font reply_font, Color reply_colr, int border_type, int border_width)
- Parameters List:
- text_height
- The text (pre-calculated) height.
- text_width
- The required text width.
- prompt_font
- The font for an output prompt.
- prompt_colr
- The colour for an output prompt.
- reply_font
- The font for the input reply.
- reply_colr
- The colour for the input reply.
- border_type
- Border type flag:
= 0, solid
= 1, raised
= 2, inset (the default)
= 3, etched out
= 4, etched in
(May use variables SOLID_FRAME, RAISED_FRAME, INSET_FRAME, ETCHED_OUT_FRAME,
ETCHED_IN_FRAME).
- border_width
- The required border width.
This section has a single method to determine the required size for
the object.
Method:
Find start size - findStartSize
Determine the required starting (minimum) size for the JdlCommandLine object
based on the relevant parameters (from pre-determined string size, border &
surround width parameters).
- Method Definition:
- public static Dimension findStartSize (int w, int h, int brdr, int surround_w, int surround_h, int r_sep)
- Parameters List:
- w
- Pre-calculated string width to allow for prompt and reply.
- h
- Pre-calculated string height.
- brdr
- Border width.
- surround_w
- The surround width.
- surround_h
- The surround height.
- r_sep
- The prompt/reply separator width.
- Method Return:
-
The calculated size (width, height).
This section contains the main methods used with normal operation
of the object.
Methods:
Output prompt - outputPrompt
Clear command line - clearLine
Output a text string prompt to the window and await reply.
- Method Definition:
- public void outputPrompt (String str)
- Parameters List:
- str
- The prompt string to be output.
This method clears the command line.
- Method Definition:
- public void clearLine ()
- Parameters List:
- none
This section has methods to set/get the resources associated with the
object determining its appearance and mode of action.
Methods:
Set surround height - setSurroundHeight
Set surround width - setSurroundWidth
Set prompt/reply separator - setReplySeparatorWidth
Set focus actions - setFocusAction
Set password mode - setPasswordMode
This method sets the surround height resource.
- Method Definition:
- public void setSurroundHeight(int h)
- Parameters List:
- h
- The minimum height required between the button border and the
top and bottom of the text (default = 2).
This method sets the surround width resource.
- Method Definition:
- public void setSurroundWidth(int w)
- Parameters List:
- w
- The minimum width required between the button border and the
left and right of the text (default = 2).
This method sets the prompt/reply separator distance resource.
- Method Definition:
- public void setReplySeparatorWidth(int sep)
- Parameters List:
- sep
- The width of the space to leave between the prompt string and
the start of the reply string (default = 4).
This method sets the option to generate actions when the keyboard focus
is lost/gained.(This method was implemented for benefit of a JdlView object
which needs to indicate the focus state in its active window e.g.
JdlCellWindow)
- Method Definition:
- public void setFocusAction(boolean on)
- Parameters List:
- on
- Set the option if true or disable it if false (the default).
This method sets password mode (input displayed as asterisks).
- Method Definition:
- public void setPasswordMode(boolean on)
- Parameters List:
- on
- =true use password input mode, =false use normal input mode.
This section contains the standard methods for positioning and sizing
the object.
Methods:
Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set constraints on the Jdl object positioning.
- Method Definition:
- public void setLocationConstraints (int constraint_x, int constraint_y)
- Parameters List:
- constraint_x
- Constrain the Jdl Object 'x' position = the required
Jdl Object 'x' position (overrides setLocation method) or FREE if the 'x'
position may be set by the setLocation method and hence possibly by the
layout manager.
- constraint_y
- Constrain the Jdl Object 'y' position = the required
the Jdl Object 'y'position (overrides setLocation method) or FREE if the 'y'
position may be set by the setLocation method and hence possibly by the
layout manager.
Set constraints on the Jdl Object resizing permitted.
- Method Definition:
- public void setSizeConstraints (int constraint_w, int constraint_h)
- Parameters List:
- constraint_w
- Constrain the Jdl Object width = the required
Jdl Object width, or PREFERRED (default) if the width is to be calculated
from the current resources, or FREE if the width may be resized to anything
greater than the minimum width required.
- constraint_h
- Constrain the Jdl Object height = the required
Jdl Object height, or PREFERRED (default) if the height is to be calculated
from the current resources, or FREE if the height may be resized to anything
greater than the minimum height required.
This section has methods to add or remove an action listener.
Methods:
Add action listener - addActionListener
Remove action listener - removeActionListener
This adds the specified action listener to receive action events from this
object.
- Method Definition:
- public void addActionListener(ActionListener listener)
- Parameters List:
- listener
- The action listener to be added.
This removes the specified action listener so that it no longer receives action
events from this object.
- Method Definition:
- public void removeActionListener(ActionListener listener)
- Parameters List:
- listener
- The action listener to be removed.
This section contains methods which override the corresponding superclass
methods. These are basically standard for JdlView objects and comprise
methods to set background and foreground colours and to get the minimum
and preferred sizes for the object. (The paintComponent method is also
over-ridden but is not normally called by the user).
Methods:
Set background - setBackground
Set background colours - setBackground
Set foreground - setForeground
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize
This method sets the background colour resource.
- Method Definition:
- public void setBackground (Color c)
- Parameters List:
- c
- The color to become this object's background color.
This method sets the background colour resource and brighter and darker shades
of that colour (e.g. for 3-D frames).
- Method Definition:
- public void setBackground (Color c, Color brighter, Color darker)
- Parameters List:
- c
- The background colour.
- brighter
- A brighter shade of the background colour.
- darker
- A darker shade of the background colour.
This method sets the foreground colour resource.
- Method Definition:
- public void setForeground (Color c)
- Parameters List:
- c
- The color to become this object's foreground color.
This method returns the minimum size of the component.
- Method Definition:
- public Dimension getMinimumSize()
- Parameters List:
- none
This method returns the preferred size of the component.
- Method Definition:
- public Dimension getPreferredSize()
- Parameters List:
- none
⇑ Up 3
⇑ Up 2
⇑ Up 1
⇑ Top of this