public class PsPanel extends java.awt.Panel implements PsUpdateIf
Panel
.
Implements the update mechanism and simplifies setting of layouts.
Each non-gui class may have associated inspectors derived from PsPanel.
Subclasses must call the init()
method in each constructor and
each init()
method must call super.init()
at first.
public class myClass extends mySuperClass public myClass() { ... if (getClass() == myClass.class) init(); } public void init() { super.init(); ... }Only this ensures that the init() method is called. Otherwise even the init() methods of the superclasses will not be called.
The default font of this class is PsConfig.FONT_TEXT
.
Class contains several static methods to simplify the updating of GUI widgets. These methods first check if the GUI is already in the requested state, and invoke the GUI methods only if the widget status must be changed.
Modifier and Type | Field and Description |
---|---|
static int |
BORDER_GROOVE |
static int |
BORDER_LINE |
static int |
BORDER_LINETOP |
static int |
BORDER_NONE |
static int |
BORDER_SUNK |
static java.lang.String |
BOUNDARY
Name of default boundary panel under which panel is registered in panel list.
|
static java.lang.String |
BOUNDARY_EXT
File name suffix of boundary panel class to name of base class.
|
static java.lang.String |
CONFIG
Name of default control panel under which panel is registered in panel list.
|
static java.lang.String |
CONFIG_EXT
File name suffix of control panel class to name of base class.
|
static java.lang.String |
INFO
Name of default info panel under which panel is registered in panel list.
|
static java.lang.String |
INFO_EXT
Identifier of class extension characterizing info panels.
|
static java.lang.String |
LABEL
Name of default font panel under which panel is registered in panel list.
|
static java.lang.String |
LABEL_EXT
File name suffix of font panel class to name of base class.
|
static java.lang.String |
MATERIAL
Name of default material panel under which panel is registered in panel list.
|
static java.lang.String |
MATERIAL_EXT
File name suffix of material panel class to name of base class.
|
static int |
ORIENT_GUIDE
Vertical handle of toolbar.
|
static int |
ORIENT_HORIZONTAL
Default horizontal orientation of lines.
|
static int |
ORIENT_VERTICAL
Vertical orientation of lines.
|
static java.lang.String |
TEXTURE
Name of default texture panel under which panel is registered in panel list.
|
static java.lang.String |
TEXTURE_EXT
File name suffix of texture panel class to name of base class.
|
static java.lang.String |
VECTOR
Name of default vector panel under which panel is registered in panel list.
|
static java.lang.String |
VECTOR_EXT
File name suffix of vector panel class to name of base class.
|
Constructor and Description |
---|
PsPanel()
Constructor of panel with
PsStackLayout(1) as default layout manager. |
PsPanel(java.awt.LayoutManager mgr)
Constructor of panel with given layout manager.
|
Modifier and Type | Method and Description |
---|---|
java.awt.Panel |
addLabelComponent(java.lang.String label,
java.awt.Component comp)
Add a label and a component in a horizontal panel with GridLayout(1, 2).
|
void |
addLine(int size)
Add a horizontal line with specified thickness as separator.
|
void |
addLine(int size,
int orient)
Add a horizontal line with specified thickness as separator.
|
java.awt.Label |
addSubTitle(java.lang.String title)
Add subtitle to panel in subheader font and return label.
|
java.awt.TextField |
addTextField(java.lang.String label,
int length)
Add a label and textField in a horizontal panel with GridLayout(1, 2).
|
java.awt.Label |
addTitle(java.lang.String title)
Create main title to panel in header font and add to panel.
|
static void |
drawBorder(java.awt.Component comp,
java.awt.Graphics g,
int borderType)
Deprecated.
use static void PsPanel.drawBorder(Graphics, borderType, Rectangle);
|
void |
drawBorder(java.awt.Graphics g,
int borderType)
Draw border around this panel.
|
static void |
drawBorder(java.awt.Graphics g,
int borderType,
java.awt.Rectangle rectangle)
Draw a rectangle into the given graphics context.
|
static void |
drawBorder(java.awt.Graphics g,
int borderType,
java.awt.Rectangle rectangle,
java.awt.Color color)
Draw a rectangle into the given graphics context with given color.
|
void |
drawText(java.awt.Graphics g,
java.awt.Point point,
java.lang.String string)
Draw text at specified position.
|
PsUpdateIf |
getFather()
Get the parent of this panel which receives update events.
|
java.awt.Insets |
getInsets()
Overwrite
Container.getInsets() to create a border
measured in pixels around this panel. |
java.lang.String |
getLanguage()
Get language used in this panel.
|
java.awt.Dimension |
getPreferredSize()
Get the assigned preferred size, or whatever super provides.
|
java.awt.Label |
getTitle()
Get the main title label, or
null of no title exists. |
java.awt.Label |
getTitle(java.lang.String title)
Create a new main title label with given string and standard font.
|
java.awt.Label |
getTitle(java.lang.String title,
java.awt.Font font)
Create a new main title label with given string and font.
|
boolean |
hasTitle()
Check whether panel has a main title label.
|
void |
init() |
boolean |
instanceOf(java.lang.String aClassName)
Deprecated.
use "if (getClass() == PsObject.class)" instead
|
void |
paint(java.awt.Graphics g)
Call
super.paint(g) and draw border around panel. |
void |
removeTitle()
Remove label of panel title from this panel.
|
static boolean |
select(java.awt.Choice widget,
int index)
Update the selected index of a choice if the new index is different from
the current selection of the widget.
|
void |
setBackColor(java.awt.Color col)
Assigned explicit background color such that container is not transparent.
|
void |
setBorderType(int borderType)
Set border of panel which is automatically drawn.
|
static boolean |
setEnabled(java.awt.Component widget,
boolean bEnable)
Assure that a component is enabled if requested.
|
void |
setImage(java.awt.Image image)
Image to be shown in the background of the canvas and set layout to null.
|
void |
setInsetSize(int size)
Set the global inset size.
|
void |
setInsetSizeHorizontal(int size)
Set the vertical inset size to be used at top and bottom of this panel.
|
void |
setInsetSizeVertical(int size)
Set the vertical inset size to be used at top and bottom of this panel.
|
static boolean |
setLabel(java.awt.Button widget,
java.lang.String text)
Set the label of a button if it is different from the current label.
|
static boolean |
setLabel(java.awt.Checkbox widget,
java.lang.String text)
Set the label of a checkbox if it is different from the current label.
|
void |
setOutOfDate(boolean state)
Mark this panel as being not synchronized with the correct data of its parent.
|
void |
setParent(PsUpdateIf parent)
Set parent of this panel which receives update events.
|
void |
setPreferredSize(int width,
int height)
Assigned preferred size.
|
static boolean |
setSelectedCheckbox(java.awt.CheckboxGroup widget,
java.awt.Checkbox checkbox)
In a checkbox group selected a checkbox if it is different from
the current selection of the widget.
|
static boolean |
setState(java.awt.Checkbox widget,
boolean bState)
Assure that a checkbox has same state than corresponding boolean flag.
|
static boolean |
setText(java.awt.Label widget,
java.lang.String text)
Update the content of a label if the new content is different from
the current content of the widget.
|
static boolean |
setText(java.awt.TextComponent widget,
java.lang.String text)
Update the content of a text field if the new content is different from
the current content of the widget.
|
java.awt.Label |
setTitle(java.lang.String title)
Set string of main title of panel but do not add title to panel.
|
void |
setVisible(boolean flag)
Override
Component.setVisible(boolean) to give panel
a chance to update its content when is becomes visible. |
void |
update(java.awt.Graphics g)
Override
Component.update(Graphics) to avoid clearing
the component if an image is available. |
boolean |
update(java.lang.Object event)
Update the class whenever a child has changed.
|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName
public static final java.lang.String BOUNDARY_EXT
public static final java.lang.String BOUNDARY
public static final java.lang.String CONFIG_EXT
public static final java.lang.String CONFIG
public static final java.lang.String INFO_EXT
public static final java.lang.String INFO
public static final java.lang.String LABEL_EXT
public static final java.lang.String LABEL
public static final java.lang.String MATERIAL_EXT
public static final java.lang.String MATERIAL
public static final java.lang.String TEXTURE_EXT
public static final java.lang.String TEXTURE
public static final java.lang.String VECTOR_EXT
public static final java.lang.String VECTOR
public static final int BORDER_NONE
public static final int BORDER_LINE
public static final int BORDER_SUNK
public static final int BORDER_GROOVE
public static final int BORDER_LINETOP
public static final int ORIENT_HORIZONTAL
public static final int ORIENT_VERTICAL
public static final int ORIENT_GUIDE
public PsPanel()
PsStackLayout(1)
as default layout manager.public PsPanel(java.awt.LayoutManager mgr)
public void init()
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Container
public void setPreferredSize(int width, int height)
public void setBackColor(java.awt.Color col)
public java.lang.String getLanguage()
public void setImage(java.awt.Image image)
Functionality might be moved into separate class in some future version.
public void setVisible(boolean flag)
Component.setVisible(boolean)
to give panel
a chance to update its content when is becomes visible.
Parent of panel usually does not update panel if panel is hidden.setVisible
in class java.awt.Component
public PsUpdateIf getFather()
setParent
allows to set this
parent.getFather
in interface PsUpdateIf
getFather()
public void setParent(PsUpdateIf parent)
The method getFather
allows to retrieve this
parent.
setParent
in interface PsUpdateIf
parent
- parent of this panelgetFather()
public boolean update(java.lang.Object event)
update
in interface PsUpdateIf
event
- carries a lot of informationPsObject
,
PsUpdateIf.getFather()
,
PsUpdateIf.setParent(PsUpdateIf)
public final boolean instanceOf(java.lang.String aClassName)
false
.
This method is different from Java operator instanceof
which
is true even if current instance is subclass of class 'aClassName'.aClassName
- name of class without package identifierspublic java.awt.Insets getInsets()
Container.getInsets()
to create a border
measured in pixels around this panel. The border is either uniformly determined
by setInsetSize(int) or by, additionally, specifying a vertical inset size
using setInsetSizeVertical(int).getInsets
in class java.awt.Container
setInsetSize(int)
,
setInsetSizeVertical(int)
,
setBorderType(int)
public void setInsetSize(int size)
public void setInsetSizeHorizontal(int size)
public void setInsetSizeVertical(int size)
public java.awt.Label getTitle()
null
of no title exists.public java.awt.Label getTitle(java.lang.String title)
public java.awt.Label getTitle(java.lang.String title, java.awt.Font font)
PsConfig.FONT_HEADER2
via PsConfig.getFont(fontID).public boolean hasTitle()
public void removeTitle()
public java.awt.Label setTitle(java.lang.String title)
public java.awt.Label addTitle(java.lang.String title)
public java.awt.Label addSubTitle(java.lang.String title)
public void addLine(int size)
size
- thickness of linepublic void addLine(int size, int orient)
size
- thickness of linepublic java.awt.TextField addTextField(java.lang.String label, int length)
label
- label shown to the left of the text fieldlength
- length of the text fieldpublic static boolean setText(java.awt.TextComponent widget, java.lang.String text)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- the gui element which shall be updatedtext
- the new text of the text fieldtrue
if the value has been update in this method.public static boolean setText(java.awt.Label widget, java.lang.String text)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- the gui element which shall be updatedtext
- the new text of the labeltrue
if the value has been update in this method.public static boolean select(java.awt.Choice widget, int index)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- the gui element which shall be updatedindex
- the new selected index of the choicetrue
if the value has been update in this method.public static boolean setSelectedCheckbox(java.awt.CheckboxGroup widget, java.awt.Checkbox checkbox)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- the gui element which shall be updatedcheckbox
- the new selected checkboxtrue
if the value has been update in this method.public static boolean setState(java.awt.Checkbox widget, boolean bState)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- CheckboxbState
- Requested new state of the checkboxtrue
if the value has been update in this method.public static boolean setLabel(java.awt.Button widget, java.lang.String text)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- Buttontext
- new label of the widgettrue
if the value has been update in this method.public static boolean setLabel(java.awt.Checkbox widget, java.lang.String text)
See additional comments in PsPanel#setEnabled(Component, boolean).
widget
- Checkboxtext
- new label of the widgettrue
if the value has been update in this method.public static boolean setEnabled(java.awt.Component widget, boolean bEnable)
Note: never call one of the static helper methods from an overwritten method with the same name. For example, if MyLabel extends Label and MyLabel#setEnabled(boolean) exists. Then an invocation of PsPanel.setEnabled(this, boolean) in MyLabel#setEnabled would lead to loop since PsPanel.setEnabled calls MyLabel#setEnabled.
widget
- ComponentbEnable
- Requested new state of the componenttrue
if the value has been update in this method.public java.awt.Panel addLabelComponent(java.lang.String label, java.awt.Component comp)
label
- text shown to the left of the componentcomp
- component shown to the right of the labelpublic void drawText(java.awt.Graphics g, java.awt.Point point, java.lang.String string)
public static void drawBorder(java.awt.Graphics g, int borderType, java.awt.Rectangle rectangle)
public static void drawBorder(java.awt.Graphics g, int borderType, java.awt.Rectangle rectangle, java.awt.Color color)
drawBorder(Graphics, int, Rectangle)
public void drawBorder(java.awt.Graphics g, int borderType)
public static void drawBorder(java.awt.Component comp, java.awt.Graphics g, int borderType)
public void setBorderType(int borderType)
borderType==PsPanel.BORDER_NONE
drawing is disabled,
otherwise the borderType is set and drawing is enabled.borderType
- type of border, for possible values see PsPanel.paint(Graphics)
public void setOutOfDate(boolean state)
public void paint(java.awt.Graphics g)
super.paint(g)
and draw border around panel.
If this panel is out of date, then this panel is first synchronized
with new data from its parent by calling this.update(m_parent).
If this panel has an image then the image is drawn before super.paint(Graphics) is called.
paint
in class java.awt.Container
setBorderType(int)
public void update(java.awt.Graphics g)
Component.update(Graphics)
to avoid clearing
the component if an image is available.update
in class java.awt.Container
"