|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.abstractics.xmlpanel.swing.XmlPanel
This subclass of JPanel provides the functionality for the layout to be
defined via XML. This class must be created through the create()
factory method.
There are various setXml()
methods that can then be called to
set the XML for they layout.
This class also implements ActionListener
The root
XmlPanel is added as an ActionListener to every
AbstractButton
object that is contained in the panel.
This allows the developer to add ActionListeners to the XmlPanel that will
get the action events for every button contained in the panel.
XmlLayout
,
Serialized FormNested Class Summary | |
static class |
XmlPanel.XmlPanelComponentCreator
ComponentCreator that creates XmlPanels. |
Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
XmlPanel()
Public empty constructor. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Passes on the action performed to all of our ActionListeners Note: If this method is overridden in a subclass, it is important to call the super method, so that anything else that registers to listen will be notified. |
void |
addActionListener(java.awt.event.ActionListener l)
Adds an ActionListener to the panel. |
static XmlPanel |
create()
Deprecated. Factory method is no longer needed. Use the XmlPanel() constructor. |
java.awt.event.ActionListener[] |
getActionListeners()
Returns an array of all the ActionListener s added to this
panel with addActionListener(). |
javax.swing.ImageIcon |
getBackgroundImage()
Gets the current background image, or null if it has not been specified |
int |
getBackgroundImageAlign()
Returns the current background image alignment Alignment values come from SwingConstants such as CENTER, NORTHWEST, etc.Default value is SwingConstants.NORTHWEST |
java.awt.Component |
getComponentNamed(java.lang.String name)
Returns the first component found in the panel with the given name. |
org.w3c.dom.Element |
getElement()
|
javax.swing.JButton |
getJButton(java.lang.String name)
Convenience method for finding a specific JButton in the panel
with the given name. |
javax.swing.JCheckBox |
getJCheckBox(java.lang.String name)
Convenience method for finding a specific JCheckBox in the panel
with the given name. |
javax.swing.JComboBox |
getJComboBox(java.lang.String name)
Convenience method for finding a specific JComboBox in the panel
with the given name. |
javax.swing.JLabel |
getJLabel(java.lang.String name)
Convenience method for finding a specific JLabel in the panel
with the given name. |
javax.swing.JRadioButton |
getJRadioButton(java.lang.String name)
Convenience method for finding a specific JRadioButton in the
panel with the given name. |
javax.swing.JTextArea |
getJTextArea(java.lang.String name)
Convenience method for finding a specific JTextArea in the panel
with the given name. |
javax.swing.JTextField |
getJTextField(java.lang.String name)
Convenience method for finding a specific JTextField in the panel
with the given name. |
XmlPanel |
getParentXmlPanel()
|
XmlPanel |
getRootXmlPanel()
|
boolean |
isBackgroundImageTileX()
Returns true if the background image is set to be tiled horizontally. |
boolean |
isBackgroundImageTileY()
Returns true if the background image is set to be tiled vertically. |
boolean |
isRootXmlPanel()
|
static void |
main(java.lang.String[] args)
Running this object results in a simple display of a panel in a window that can then be used to design an initial layout |
void |
paint(java.awt.Graphics g)
Overridden to draw the cell border lines when in edit mode. |
protected void |
paintComponent(java.awt.Graphics g)
Overriden to handle the painting of the background image, if there is one |
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an ActionListener from the panel. |
void |
setAllowEditorDialog(boolean allowEditorDialog)
Controls if the panel allows double-right-click editing on the panel. A System property for xmlpanel.allowEditorDialog can also
be set to true which will cause all panels to allow the
editing, regardless of this setting. |
void |
setBackgroundImage(javax.swing.ImageIcon image)
Sets an image that should be painted one the background of the panel. |
void |
setBackgroundImageAlign(int align)
If a background image has been specified using setBackgroundImage(ImageIcon) and
isBackgroundImageTileX() is false, then this setting can be used
to control the placement of the image on the panel.Use SwingConstants alignment variables (CENTER, NORTHWEST, etc.)
to specify the alignment.Default setting is SwingConstants.NORTHWEST |
void |
setBackgroundImageAlign(java.lang.String align)
Provided so the alignment can be set from XML. |
void |
setBackgroundImageTileX(boolean tiled)
If a background image has been specified using setBackgroundImage(ImageIcon) , then setting this property to
true will cause the image to be repeatedly painted from left to right,
and the vertical placement will be determined by
getBackgroundImageAlign() - NORTH, CENTER, or SOUTH.If both the X and Y tiling are on, then the image will be tiled everywhere, starting at the northwest corner. Default setting is false. |
void |
setBackgroundImageTileY(boolean tiled)
If a background image has been specified using setBackgroundImage(ImageIcon) , then setting this property to
true will cause the image to be repeatedly painted from top to bottom,
and the horizontal placement will be determined by
getBackgroundImageAlign() - WEST, CENTER, or EAST.If both the X and Y tiling are on, then the image will be tiled everywhere, starting at the northwest corner. Default setting is false. |
void |
setXml(java.io.File file)
|
void |
setXml(java.io.InputStream stream)
|
void |
setXml(java.io.Reader reader)
|
void |
setXml(java.lang.String xml)
|
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XmlPanel()
Method Detail |
public static XmlPanel create()
XmlPanel()
constructor.
public static void main(java.lang.String[] args)
args
- public void setBackgroundImage(javax.swing.ImageIcon image)
image
- image to paint in the backgroundpublic javax.swing.ImageIcon getBackgroundImage()
public void setBackgroundImageTileX(boolean tiled)
setBackgroundImage(ImageIcon)
, then setting this property to
true will cause the image to be repeatedly painted from left to right,
and the vertical placement will be determined by
getBackgroundImageAlign()
- NORTH, CENTER, or SOUTH.
tiled
- set to true to tile the background image horizontallypublic void setBackgroundImageTileY(boolean tiled)
setBackgroundImage(ImageIcon)
, then setting this property to
true will cause the image to be repeatedly painted from top to bottom,
and the horizontal placement will be determined by
getBackgroundImageAlign()
- WEST, CENTER, or EAST.
tiled
- set to true to tile the background image verticallypublic void setBackgroundImageAlign(int align)
setBackgroundImage(ImageIcon)
and
isBackgroundImageTileX()
is false, then this setting can be used
to control the placement of the image on the panel.SwingConstants
alignment variables (CENTER, NORTHWEST, etc.)
to specify the alignment.SwingConstants.NORTHWEST
align
- the alignment to use for the background imagepublic void setBackgroundImageAlign(java.lang.String align)
SwingUtils.convertStringAlign(String, int)
and then is passed to
the setBackgroundImageAlign(int)
method.
align
- the alignment to use for the background imagepublic void setXml(java.lang.String xml) throws XmlException
xml
-
XmlException
- Thrown if an error occurs in reading or parsing the XML
java.lang.UnsupportedOperationException
- Thrown if this panel is not a root XmlPanel - XML can only be
set on the root panel.public void setXml(java.io.Reader reader) throws XmlException
reader
-
XmlException
- Thrown if an error occurs in reading or parsing the XML
java.lang.UnsupportedOperationException
- Thrown if this panel is not a root XmlPanel - XML can only be
set on the root panel.public void setXml(java.io.File file) throws XmlException, java.io.FileNotFoundException
file
-
XmlException
- Thrown if an error occurs in reading or parsing the XML
java.io.FileNotFoundException
- Thrown if the given file cannot be read
java.lang.UnsupportedOperationException
- Thrown if this panel is not a root XmlPanel - XML can only be
set on the root panel.public void setXml(java.io.InputStream stream) throws XmlException
stream
-
XmlException
- Thrown if an error occurs in reading or parsing the XML
java.lang.UnsupportedOperationException
- Thrown if this panel is not a root XmlPanel - XML can only be
set on the root panel.public java.awt.Component getComponentNamed(java.lang.String name)
name
-
java.lang.IllegalArgumentException
- Thrown if a component cannot be found with the given name.SwingUtils.getChildNamed(String, Container)
public javax.swing.JTextField getJTextField(java.lang.String name)
JTextField
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JTextArea getJTextArea(java.lang.String name)
JTextArea
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JLabel getJLabel(java.lang.String name)
JLabel
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JCheckBox getJCheckBox(java.lang.String name)
JCheckBox
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JButton getJButton(java.lang.String name)
JButton
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JRadioButton getJRadioButton(java.lang.String name)
JRadioButton
in the
panel with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic javax.swing.JComboBox getJComboBox(java.lang.String name)
JComboBox
in the panel
with the given name. Recursively searches through all children,
grandchildren, etc. If not found, an exception is thrown. The exception
is thrown so that errors are more informative, rather than return a null
which would result in confusing NullPointerExceptions
name
- Name of the component
java.lang.IllegalArgumentException
- Thrown if the component could not be found, or if it was
found but is not the correct typepublic org.w3c.dom.Element getElement()
public XmlPanel getParentXmlPanel()
public XmlPanel getRootXmlPanel()
public boolean isRootXmlPanel()
public void setAllowEditorDialog(boolean allowEditorDialog)
xmlpanel.allowEditorDialog
can also
be set to true
which will cause all panels to allow the
editing, regardless of this setting.
allowEditorDialog
- Set to true to allow the double-right-click editing of the
panel.public void paint(java.awt.Graphics g)
Component.paint(java.awt.Graphics)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
ActionListener.actionPerformed(java.awt.event.ActionEvent)
public void addActionListener(java.awt.event.ActionListener l)
ActionListener
to the panel. This ActionListener
will receive notification from every AbstractButton in the panel.
l
- the ActionListener
to be addedpublic java.awt.event.ActionListener[] getActionListeners()
ActionListener
s added to this
panel with addActionListener().
ActionListener
s added or an empty
array if no listeners have been addedpublic void removeActionListener(java.awt.event.ActionListener l)
ActionListener
from the panel.
l
- the listener to be removedprotected void paintComponent(java.awt.Graphics g)
JComponent.paintComponent(java.awt.Graphics)
public int getBackgroundImageAlign()
SwingConstants
such as CENTER, NORTHWEST, etc.SwingConstants.NORTHWEST
public boolean isBackgroundImageTileX()
getBackgroundImageAlign()
- NORTH, CENTER, or
SOUTH.
public boolean isBackgroundImageTileY()
getBackgroundImageAlign()
- WEST, CENTER, or
EAST.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |