3.4.3 - I/O Window - JdlIOWindow

John W. Campbell

3.4.3.1 Introduction

This class provides a window for the input and output of text strings. A command recall facility is implemented and cutting/pasting can be done.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Constructor
Operational Methods
Add/Remove Action Listener
Get Returned Data
Overriden Superclass Methods

3.4.3.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlIOWindow
Class definition:
public class JdlIOWindow
Extends:
JdlDrawPanel
Implements:
FocusListener
MouseListener
KeyListener
ActionListener
ChangeListener
JdlViewObject
Actions:
An action event will be generated when a (command) string is input. The associated object is the input string.

3.4.3.3 Accessible Fields

The following accessible fields have been defined:

public final static int PREFERRED
Size Constraint: preferred size.
public final static int FREE
Size/Location Constraint: free.
static final long serialVersionUID

3.4.3.4 Constructor

3.4.3.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

3.4.3.4.2 Standard constructor

Constructs a JdlIOWindow object with the required resources.

Constructor Definition:
public JdlIOWindow(int rows, int cols, String typical, JdlViewOptions view_opts)
Parameters List:
rows
The required number of rows if characters.
cols
The required number of columns of characters.
typical
A typical string for defining the character column width. If null then the width of the character 'm' is used by default.
view_opts
Object to set non-default options for borders, active strip, colours and fonts.

3.4.3.5 Operational Methods

3.4.3.5.1 Introduction

This section has methods to output a text string, to enable text input and to enable editing of a reply string.

Methods:

Output a text string - outputString
Set input mode - setInputMode
Set editable reply - setEditableReplyString
Set Font - setFontType
Set Tabs - setTabSize
Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set minimum height - setMinimumHeight
Set minimum width - setMinimumWidth

3.4.3.5.2 Output a text string - outputString

This method outputs a text string to the window with a selected carriage control option. Note: If input mode is currently on then input mode will be turned off.

Method Definition:
public void outputString (String str, int nl)
Parameters List:
str
The string to be output including any newline (\n) characters required. The characters \f, \v, \r will be treated as newline characters. For strings without newline characters, use the 'nl' flag to handle any newline requirements.
nl
Newline flag:
= 0, do not add any newline characters to the string
= 1, add one before outputting the string
= 2, add one after outputting the string
= 3, add one before and after outputting the string

3.4.3.5.3 Set input mode - setInputMode

This method sets (or unsets) text (command) input mode.

Method Definition:
public void setInputMode (boolean on)
Parameters List:
on
True for on, else false for off.

3.4.3.5.4 Set editable reply - setEditableReplyString

This method outputs an editable reply string (also sets the text input mode to 'on'). The reply may be edited, as needed, before confirming it using the Enter key.

Method Definition:
public void setEditableReplyString (String reply)
Parameters List:
reply
The reply string to be edited.

3.4.3.5.5 Set Font - setFontType

This method selects a new font for the text window from the set of 'standard' fonts.

Method Definition:
public void setFontType(int ifont)
Parameters List:
ifont
Font type code:
= 1, standard font
= 2, standard bold font
= 3, standard italic font
= 4, fixed font
= 5, fixed bold font
= 6, fixed italic font
= 7, small fixed font

3.4.3.5.6 Set Tabs - setTabSize

This method sets the tab width for the text area.

Method Definition:
public void setTabSize(int nc)
Parameters List:
none

3.4.3.5.7 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.4.3.5.8 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.4.3.5.9 Set minimum height - setMinimumHeight

Set the minimum height resource.

Method Definition:
public void setMinimumHeight(int minh)
Parameters List:
minh
The minimum height required for the object (ignored if less than that required by the minimum layout) (default = 0).

3.4.3.5.10 Set minimum width - setMinimumWidth

Set the minimum width resource.

Method Definition:
public void setMinimumWidth(int minw)
Parameters List:
minh
The minimum width required for the object (ignored if less than that required by the minimum layout) (default = 0).

3.4.3.6 Add/Remove Action Listener

3.4.3.6.1 Introduction

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

Methods:

Add action listener - addActionListener
Remove action listener - removeActionListener

3.4.3.6.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.4.3.6.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.4.3.7 Get Returned Data

3.4.3.7.1 Introduction

This section has methods to get data from the object relating to an action and following that action.

Methods:

Get input string - getReturnedData

3.4.3.7.2 Get input string - getReturnedData

This method returns the last the input string.

Method Definition:
public String getReturnedData()
Parameters List:
none
Method Return:
Returns the last input string.

3.4.3.8 Overriden Superclass Methods

3.4.3.8.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 and setSize methods are also over-ridden but they are 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.4.3.8.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.4.3.8.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.4.3.8.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.4.3.8.5 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

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

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