3.10.14 - Command Line - JdlCommandLine

John W. Campbell

3.10.14.1 Introduction

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

3.10.14.2 Class Details

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>>".

3.10.14.3 Accessible Fields

The following accessible fields have been defined:

public final static int FREE
Location Constraint: free.
static final long serialVersionUID

3.10.14.4 Constructor

3.10.14.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

3.10.14.4.2 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.

3.10.14.5 Class Methods

3.10.14.5.1 Introduction

This section has a single method to determine the required size for the object.

Method:

Find start size - findStartSize

3.10.14.5.2 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).

3.10.14.6 Operational Methods

3.10.14.6.1 Introduction

This section contains the main methods used with normal operation of the object.

Methods:

Output prompt - outputPrompt
Clear command line - clearLine

3.10.14.6.2 Output prompt - outputPrompt

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.

3.10.14.6.3 Clear command line - clearLine

This method clears the command line.

Method Definition:
public void clearLine ()
Parameters List:
none

3.10.14.7 Resource Methods

3.10.14.7.1 Introduction

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

3.10.14.7.2 Set surround height - setSurroundHeight

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).

3.10.14.7.3 Set surround width - setSurroundWidth

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).

3.10.14.7.4 Set prompt/reply separator - setReplySeparatorWidth

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).

3.10.14.7.5 Set focus actions - setFocusAction

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).

3.10.14.7.6 Set password mode - setPasswordMode

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.

3.10.14.8 Standard Positioning and Sizing

3.10.14.8.1 Introduction

This section contains the standard methods for positioning and sizing the object.

Methods:

Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints

3.10.14.8.2 Set position constraints - setLocationConstraints

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.

3.10.14.8.3 Set size constraints - setSizeConstraints

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.

3.10.14.9 Add/Remove Action Listener

3.10.14.9.1 Introduction

This section has methods to add or remove an action listener.

Methods:

Add action listener - addActionListener
Remove action listener - removeActionListener

3.10.14.9.2 Add action listener - addActionListener

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.

3.10.14.9.3 Remove action listener - removeActionListener

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.

3.10.14.10 Overriden Superclass Methods

3.10.14.10.1 Introduction

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

3.10.14.10.2 Set background - setBackground

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.

3.10.14.10.3 Set background colours - setBackground

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.

3.10.14.10.4 Set foreground - setForeground

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.

3.10.14.10.5 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

Method Definition:
public Dimension getMinimumSize()
Parameters List:
none

3.10.14.10.6 Get preferred size - getPreferredSize

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