3.6.2 - Address Window - JdlAddressWindow.java

John W. Campbell

3.6.2.1 Introduction

This class provides a window for the input/editing/display of an address book entry.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Constructor
Set Address Details
Editing the Address
Standard Positioning and Sizing
Add/Remove Action Listener
Get Returned Data
Overriden Superclass Methods

3.6.2.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlAddressWindow
Class definition:
public class JdlAddressWindow
Extends:
JdlDrawPanel
Implements:
ChangeListener
KeyListener
ActionListener
JdlViewObject
Actions:
An action event will be generated when either an item in the address window is edited (Action command starts with the string "Edit:") or when one of the buttons is pressed (Action command starts with the string "Button:"). The command string indicates which item has been edited or which button has been pressed as follows:
Edit: mult
Edit: mobile_main
Edit: section
Edit: sort_key
Edit: mail_address
Edit: post_code
Edit: mail_header
Edit: letter_header
Edit: tel_no
Edit: mobile_no
Edit: email_address
Edit: group_names
Edit: birth_date
Edit: notes_header
Button: OK
Button: Apply
Button: Reset
Button: Cancel

3.6.2.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.
public final static int NO_BUTTONS
Buttons option: none.
public final static int APPLY_AND_RESET
Buttons option: Apply & Reset.
public final static int ALL_BUTTONS
Buttons option: OK, Apply, Reset & Cancel.
static final long serialVersionUID

3.6.2.4 Constructor

3.6.2.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

3.6.2.4.2 Standard constructor

Constructs a JdlAddressWindow with the required resources.

Constructor Definition:
public JdlAddressWindow(int but_opt, JdlViewOptions view_opts)
Parameters List:
but_opt
Buttons option:
= 0, none - NO_BUTTONS
= 1, Apply & Reset buttons to be shown - APPLY_AND_RESET
= 2, OK, Apply, Reset & Cancel to be shown - ALL_BUTTONS
view_opts
Object to set non-default options for borders, active strip, colours and fonts.

3.6.2.5 Set Address Details

3.6.2.5.1 Introduction

This section has methods to set the various items which for an address book entry.

Methods:

Set sections list - setSectionStrings
Set address entry - setAddressEntry
Set address entry - setAddressEntry

3.6.2.5.2 Set sections list - setSectionStrings

This method sets the Address Book 'sections' list.

Method Definition:
public void setSectionStrings (String[] strs)
Parameters List:
strs
Section name strings for popup menu (min. of 1 string).

3.6.2.5.3 Set address entry - setAddressEntry

This method sets an address entry using a JdlAddressEntry object.

Method Definition:
public void setAddressEntry (JdlAddressEntry entry)
Parameters List:
entry
The address book entry to be listed (null will clear entry)

3.6.2.5.4 Set address entry - setAddressEntry

Set an address entry using a JdlAddressEntry object and display the details for a selected individual from the entry.

Method Definition:
public void setAddressEntry (JdlAddressEntry entry, int idx)
Parameters List:
entry
The address book entry to be listed (null will clear entry)
idx
The index of the individual to be displayed.

3.6.2.6 Editing the Address

3.6.2.6.1 Introduction

This section has method relating to the control of editing the address and monitoring edits made.

Methods:

Set editable state - setEditable
Clear changes flag - clearChanged
Reset entry - resetEntry
Get last changed string - lastChangedString
Get entry - getChangedEntry
See if changed - wasChanged

3.6.2.6.2 Set editable state - setEditable

This method sets editable state of the contents of the address window.

Method Definition:
public void setEditable(boolean edt)
Parameters List:
edt
Edit state flag:
= true, Set editable
= false, Set uneditable

3.6.2.6.3 Clear changes flag - clearChanged

This method clears the address entry changed flag. It will be set again if any further edits are made.

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

3.6.2.6.4 Reset entry - resetEntry

This method will reset the entry to the state it was in when the setAddressEntry(..) method was called. Note: This will clear the entry changed flag.

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

3.6.2.6.5 Get last changed string - lastChangedString

This method returns the last changed string (following an Edit action).

Method Definition:
public String lastChangedString()
Parameters List:
none
Method Return:
The string.

3.6.2.6.6 Get entry - getChangedEntry

This method gets a changed (edited) address entry in its current state.

Method Definition:
public JdlAddressEntry getChangedEntry()
Parameters List:
none
Method Return:
A new (cloned) JdlAddressEntry object.

3.6.2.6.7 See if changed - wasChanged

See if an entry was changed since last setAddressEntry(..) or clearChanged(..) method call.

Method Definition:
public boolean wasChanged()
Parameters List:
none
Method Return:
true if changed, false if no changes made.

3.6.2.7 Standard Positioning and Sizing

3.6.2.7.1 Introduction

This section contains the standard methods for positioning and sizing JdlView objects and getting the current minimum height and width values.

Methods:

Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set minimum height - setMinimumHeight
Set minimum width - setMinimumWidth

3.6.2.7.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.6.2.7.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.6.2.7.4 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.6.2.7.5 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.6.2.8 Add/Remove Action Listener

3.6.2.8.1 Introduction

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

Methods:

Add action listener - addActionListener
Remove action listener - removeActionListener

3.6.2.8.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.6.2.8.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.6.2.9 Get Returned Data

3.6.2.9.1 Introduction

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

Methods:

Get input - getReturnedData

3.6.2.9.2 Get input - getReturnedData

This method is a dummy for this object. Details of the action event are returned in the action event command string.

Method Definition:
public int getReturnedData()
Parameters List:
none
Method Return:
Returns 0.

3.6.2.10 Overriden Superclass Methods

3.6.2.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 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.6.2.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.6.2.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.6.2.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.6.2.10.5 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

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

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