3.9.4 - Framed Panel - JdlFramedPanel

John W. Campbell

3.9.4.1 Introduction

This class provides a framed panel for drawing on or for sub-classing to make buttons etc.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Constructors
Set/Get Framed Panel Resources
Framed Panel Drawer Methods
Standard Positioning and Sizing
Overriden Superclass Methods

3.9.4.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlFramedPanel
Class definition:
public class JdlFramedPanel
Extends:
JPanel
Implements:
none
Actions:
none

3.9.4.3 Accessible Fields

The following accessible fields have been defined:

public final static int SOLID_FRAME
Frame type option: solid.
public final static int RAISED_FRAME
Frame type option: raised.
public final static int INSET_FRAME
Frame type option: inset.
public final static int ETCHED_OUT_FRAME
Frame type option: etched out.
public final static int ETCHED_IN_FRAME
Frame type option: etched in.
public final static int PREFERRED
Size Constraint: preferred size.
public final static int FREE
Size/Location Constraint: free.
static final long serialVersionUID

3.9.4.4 Constructors

3.9.4.4.1 Introduction

Three constructors are available.

Constructor:

Default constructor
Constructor 2
Constructor 3

3.9.4.4.2 Default constructor

Constructs a framed panel with default resources (height=10, width=25, inset frame, background based colours).

Constructor Definition:
public JdlFramedPanel ()
Parameters List:
none

3.9.4.4.3 Constructor 2

Constructs a framed panel with a given size (inset frame, background based colours).

Constructor Definition:
public JdlFramedPanel (int w, int h)
Parameters List:
w
The required width in pixels (including frame).
h
The required height in pixels (including frame).

3.9.4.4.4 Constructor 3

Constructs a framed panel with a given size and frame colours (inset frame).

Constructor Definition:
public JdlFramedPanel (int w, int h, Color fill, Color brdr, Color brdr_brighter, Color brdr_darker)
Parameters List:
w
The required width in pixels (including frame).
h
The required height in pixels (including frame).
fill
The fill colour for the panel. If null (the default), then the background colour will be used.
brdr
The border colour - sets the colour for a solid border.
brdr_brighter
A brighter colour for a three dimensional button border.
brdr_darker
A darker colour for a three dimensional button border.

3.9.4.5 Set/Get Framed Panel Resources

3.9.4.5.1 Introduction

This section has a series of methods to set and get values of the objects resources including colours, border type and thickness and panel size.

Methods:

Set border colour - setBorderColor
Set border colour - setBorderColor
Get border colour - getBorderColor
Set border thickness - setBorderThickness
Get border thickness - getBorderThickness
Set border type - setBorderType
Get border type - getBorderType
Set fill colour - setFillColor
Get fill colour - getFillColor
Set panel height - setPanelHeight
Get panel height - getPanelHeight
Set panel width - setPanelWidth
Get panel width - getPanelWidth

3.9.4.5.2 Set border colour - setBorderColor

This method sets the border colour resource.

Method Definition:
public void setBorderColor (Color colr)
Parameters List:
colr
The border colour - sets this colour for a solid border or lighter and darker shades of if for a three dimensional button border. If null (the default), use the background colour if a three dimensional button or the foreground colour if the button has a solid border.

3.9.4.5.3 Set border colour - setBorderColor

This method sets the border colour resources.

Method Definition:
public void setBorderColor (Color colr, Color brighter, Color darker)
Parameters List:
colr
The border colour - sets the colour for a solid border.
brighter
A brighter colour for a three dimensional button border.
darker
A darker colour for a three dimensional button border.

3.9.4.5.4 Get border colour - getBorderColor

This method returns the border colour resource.

Method Definition:
public Color getBorderColor()
Parameters List:
none
Method Return:
Returns the border colour resource as set.

3.9.4.5.5 Set border thickness - setBorderThickness

This method sets the border thickness resource.

Method Definition:
public void setBorderThickness (int border)
Parameters List:
thickness
This is the required border thickness in pixels. (default = 4)

3.9.4.5.6 Get border thickness - getBorderThickness

This method returns the border thickness resource.

Method Definition:
public int getBorderThickness()
Parameters List:
none
Method Return:
Returns the border thickness in pixels.

3.9.4.5.7 Set border type - setBorderType

This method sets the border type resource.

Method Definition:
public void setBorderType (int type)
Parameters List:
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).

3.9.4.5.8 Get border type - getBorderType

This method returns the border type resource.

Method Definition:
public int getBorderType()
Parameters List:
none
Method Return:
Returns the current border type flag (see setBorderType(..) method for details).

3.9.4.5.9 Set fill colour - setFillColor

This method sets the fill colour resource.

Method Definition:
public void setFillColor (Color fill_color)
Parameters List:
colr
The fill colour for the panel. If null (the default), then the background colour will be used.

3.9.4.5.10 Get fill colour - getFillColor

This method returns the fill colour resource.

Method Definition:
public Color getFillColor()
Parameters List:
none
Method Return:
Returns the current value of the fill colour resource.

3.9.4.5.11 Set panel height - setPanelHeight

This method sets the panel height resource.

Method Definition:
public void setPanelHeight (int height)
Parameters List:
height
The required panel height in pixels.

3.9.4.5.12 Get panel height - getPanelHeight

This method returns the panel height resource.

Method Definition:
public int getPanelHeight()
Parameters List:
none
Method Return:
Returns the requested panel height in pixels.

3.9.4.5.13 Set panel width - setPanelWidth

This method sets the panel width resource.

Method Definition:
public void setPanelWidth (int width)
Parameters List:
width
The required panel width in pixels.

3.9.4.5.14 Get panel width - getPanelWidth

This method returns the panel width resource.

Method Definition:
public int getPanelWidth()
Parameters List:
none
Method Return:
Returns the requested panel width in pixels.

3.9.4.6 Framed Panel Drawer Methods

3.9.4.6.1 Introduction

This section contains methods for setting and getting the panel drawer resources.

Methods:

Set drawer - setDrawer
Get drawer - getDrawer
Get drawer ID - getDrawerId

3.9.4.6.2 Set drawer - setDrawer

This method sets the JdlFramedPanelDrawer object resource.

Method Definition:
public void setDrawer (JdlFramedPanelDrawer dr, int id)
Parameters List:
dr
A JdlFramedPanelDrawer interfaced object to carry out the drawing on the panel (default = null). Its jdl_framed_panel_drawer method is called from the paint routine after the border has been drawn and after a clip area within the border has been set. Note that the coordinate origin remains as that of the complete panel including the border.
id
Identifier to be passed to the drawing method when called.

3.9.4.6.3 Get drawer - getDrawer

This method returns the JdlFramedPanelDrawer object resource.

Method Definition:
public JdlFramedPanelDrawer getDrawer()
Parameters List:
none
Method Return:
Returns the currently installed JdlFramedPanelDrawer object or null if none has been set up.

3.9.4.6.4 Get drawer ID - getDrawerId

This method returns the JdlFramedPanelDrawer identifier resource.

Method Definition:
public int getDrawerId()
Parameters List:
none
Method Return:
Returns the identifier of the currently installed JdlFramedPanelDrawer object.

3.9.4.7 Standard Positioning and Sizing

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

3.9.4.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.9.4.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.9.4.8 Overriden Superclass Methods

3.9.4.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 method is also over-ridden but is not normally called by the user).

Methods:

Set background - setBackground
Set foreground - setForeground
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize
Set size - setSize

3.9.4.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.9.4.8.3 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.9.4.8.4 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

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

3.9.4.8.5 Get preferred size - getPreferredSize

This method returns the preferred size of the component.

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

3.9.4.8.6 Set size - setSize

This method sets the panel width and panel height.

Method Definition:
public void setSize(int w, int h)
Parameters List:
w
The required panel width in pixels.
h
The required panel height in pixels.

⇑ Up 3   ⇑ Up 2   ⇑ Up 1   ⇑ Top of this