public class ButtonComponent extends ContentComponent
Modifier and Type | Class and Description |
---|---|
static class |
ButtonComponent.ButtonState
Indicates the state of a button.
|
static class |
ButtonComponent.ButtonType
Indicates the behavior of the button.
|
eventListenerList
Constructor and Description |
---|
ButtonComponent()
Initializes a new instance of the ButtonComponent class.
|
Modifier and Type | Method and Description |
---|---|
void |
addButtonComponentListener(ButtonComponentListener listener)
Registers an event listener.
|
void |
draw(java.awt.Graphics2D g2d,
RenderOptions options)
ComponentBase.draw override.
|
protected void |
fireCustomDraw(ButtonDrawEventArgs e)
Raises the customDraw event.
|
protected void |
fireOnClicked(ComponentMouseEvent e)
Raises the mouseClicked event.
|
protected void |
fireRepeatEnded(ComponentEvent e)
Raises the repeatEnded event.
|
Brush |
getBrush()
Gets the background brush of the button when it is in normal state.
|
Brush |
getBrushHovered()
Gets the background brush of the button when it is in hovered state.
|
Brush |
getBrushPressed()
Gets the background brush of the button when it is in pressed state.
|
CursorHint |
getCursor(java.awt.geom.Point2D point)
ComponentBase.getCursor override.
|
XDimension2D.Double |
getDesiredSize(XDimension2D.Double availableSize,
java.awt.Graphics2D g2d)
ComponentBase.getDesiredSize override.
|
protected java.awt.Image |
getImage()
Gets the image from the button's image list corresponding to
the current state of the button.
|
java.util.ArrayList<java.awt.Image> |
getImageList()
Gets a list with images.
|
Pen |
getPen()
Gets the border pen of the button when it is in normal state.
|
Pen |
getPenHovered()
Gets the border pen of the button when it is in hovered state.
|
Pen |
getPenPressed()
Gets the border pen of the button when it is in pressed state.
|
protected ButtonComponent.ButtonState |
getState()
Gets the current state of the button
|
ButtonComponent.ButtonType |
getType()
Gets the type of the button.
|
protected void |
loadFromJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Deserializes the component from a JsonObject.
|
protected void |
loadFromXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
ComponentBase.loadFromXml override.
|
boolean |
onKeyDown(int keyCode,
int modifiers)
ComponentBase.onKeyDown override.
|
void |
onMouseDown(java.awt.geom.Point2D point)
ComponentBase.onMouseDown override.
|
void |
onMouseMove(java.awt.geom.Point2D point)
ComponentBase.onMouseMove override.
|
void |
onMouseUp(java.awt.geom.Point2D point)
ComponentBase.onMouseUp override.
|
void |
readExternal(java.io.ObjectInput in)
ComponentBase.readExternal override.
|
void |
removeButtonComponentListener(ButtonComponentListener listener)
Unregisters an event listener.
|
protected void |
saveToJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Serializes the component into a JsonObject.
|
protected void |
saveToXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
ComponentBase.saveToXml override.
|
void |
setBrush(Brush value)
Sets the background brush of the button when it is in normal state.
|
void |
setBrushHovered(Brush value)
Sets the background brush of the button when it is in hovered state.
|
void |
setBrushPressed(Brush value)
Sets the background brush of the button when it is in pressed state.
|
void |
setImageList(java.util.ArrayList<java.awt.Image> value)
Sets a list with images.
|
void |
setPen(Pen value)
Sets the border pen of the button when it is in normal state.
|
void |
setPenHovered(Pen value)
Sets the border pen of the button when it is in hovered state.
|
void |
setPenPressed(Pen value)
Sets the border pen of the button when it is in pressed state.
|
void |
setType(ButtonComponent.ButtonType value)
Sets the type of the button.
|
void |
writeExternal(java.io.ObjectOutput out)
ComponentBase.writeExternal override.
|
accept, addChild, arrangeComponents, getChildCount, getContent, getPadding, getThickness, setContent, setPadding
addComponentEventListener, addComponentMouseEventListener, addComponentValidationEventListener, confirmValidating, contains, createOutlinePath, find, getBounds, getDocumentBounds, getFocusable, getGridColumn, getGridRow, getHeight, getHorizontalAlignment, getIsEnabled, getIsFocused, getIsHitTestVisible, getIsInteractive, getName, getParent, getParentHost, getVerticalAlignment, getVisible, getWidth, invalidate, invalidateLayout, onAddedToParent, onContextChanged, onGotFocus, onGotFocus, onKeyPress, onKeyUp, onLostFocus, onLostFocus, onMouseDown, onMouseMove, onMouseUp, onRemovedFromParent, onUnitChanged, onValidated, onValidating, onZoomChanged, raiseValidated, removeComponentEventListener, removeComponentMouseEventListener, removeComponentValidationEventListener, serializeSubcomponents, setBounds, setFocusable, setGridColumn, setGridRow, setHeight, setHorizontalAlignment, setIsEnabled, setIsFocused, setIsHitTestVisible, setIsInteractive, setName, setParent, setVerticalAlignment, setVisible, setWidth, toDocument, toLocal, toParent
public ButtonComponent()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class ContentComponent
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class ContentComponent
java.io.IOException
java.lang.ClassNotFoundException
protected void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
saveToXml
in class ContentComponent
xmlElement
- An Element the component's data should be stored into.context
- An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.protected void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context) throws javax.xml.transform.TransformerException
loadFromXml
in class ContentComponent
xmlElement
- An Element containing the component's data.context
- An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.javax.xml.transform.TransformerException
protected void saveToJson(com.mindfusion.common.JsonObject obj, JsonPersistContext context)
ContentComponent
saveToJson
in class ContentComponent
obj
- An JsonObject containing the ButtonComponent datacontext
- An JsonPersistContext object providing information
about the serialization process and some helper methods.protected void loadFromJson(com.mindfusion.common.JsonObject obj, JsonPersistContext context)
ContentComponent
loadFromJson
in class ContentComponent
obj
- An JsonObject containing the ButtonComponent datacontext
- An JsonPersistContext object providing information
about the serialization process and some helper methods.public void draw(java.awt.Graphics2D g2d, RenderOptions options)
draw
in class ContentComponent
g2d
- The drawing target.options
- A RenderOptions object specifying the drawing context.public XDimension2D.Double getDesiredSize(XDimension2D.Double availableSize, java.awt.Graphics2D g2d)
getDesiredSize
in class ContentComponent
availableSize
- The available size.g2d
- A relevant Graphics2D object.public void onMouseDown(java.awt.geom.Point2D point)
onMouseDown
in class ComponentBase
point
- A Point2D.Float instance that specifies the current mouse position.public void onMouseMove(java.awt.geom.Point2D point)
onMouseMove
in class ComponentBase
point
- A Point2D.Float instance that specifies the current mouse position.public void onMouseUp(java.awt.geom.Point2D point)
onMouseUp
in class ComponentBase
point
- A Point2D.Float instance that specifies the current mouse position.public CursorHint getCursor(java.awt.geom.Point2D point)
getCursor
in class ComponentBase
point
- A Point2D.Float instance that specifies the current mouse position, in document coordinates.public boolean onKeyDown(int keyCode, int modifiers)
onKeyDown
in class ComponentBase
protected java.awt.Image getImage()
protected void fireOnClicked(ComponentMouseEvent e)
e
- An object containing the event data.protected void fireRepeatEnded(ComponentEvent e)
e
- An object containing the event data.protected void fireCustomDraw(ButtonDrawEventArgs e)
e
- An object containing the event data.public void addButtonComponentListener(ButtonComponentListener listener)
listener
- An object implementing ButtonComponentListener interface.public void removeButtonComponentListener(ButtonComponentListener listener)
listener
- An object implementing ButtonComponentListener interface.protected ButtonComponent.ButtonState getState()
public void setBrush(Brush value)
value
- An instance of the Brush class.public Brush getBrush()
public void setBrushHovered(Brush value)
value
- An instance of the Brush class.public Brush getBrushHovered()
public void setBrushPressed(Brush value)
value
- An instance of the Brush class.public Brush getBrushPressed()
public void setPen(Pen value)
value
- An instance of the Pen class.public Pen getPen()
public void setPenHovered(Pen value)
value
- An instance of the Pen class.public Pen getPenHovered()
public void setPenPressed(Pen value)
value
- An instance of the Pen class.public Pen getPenPressed()
public void setImageList(java.util.ArrayList<java.awt.Image> value)
value
- A list of java.awt.Image objects.public java.util.ArrayList<java.awt.Image> getImageList()
public void setType(ButtonComponent.ButtonType value)
value
- A member of the ButtonType enumerator.public ButtonComponent.ButtonType getType()