Package fr.formiko.views.gui2d
Class FButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
fr.formiko.views.gui2d.FButton
- All Implemented Interfaces:
MouseListener
,ImageObserver
,ItemSelectable
,MenuContainer
,Serializable
,EventListener
,Accessible
,SwingConstants
- Direct Known Subclasses:
BoutonLong
,FButtonLink
,FButtonPGO
,FPanelMiniMapContainer.FButtonEndTurn
Extends of Button with some added functions.
There is a default color for normal button, focus button & disable button.
Defaults colors are in Data.
There is a default color for normal button, focus button & disable button.
Defaults colors are in Data.
- Author:
- Hydrolien
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JButton
JButton.AccessibleJButton
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected boolean
protected boolean
protected int
protected static int
protected boolean
protected final int
protected Image
protected boolean
protected String
protected FPanel
protected boolean
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fields inherited from class javax.swing.JComponent
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.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
return background color with or without alpha.getCFont()
protected String
getDesc()
Return the description of the button.static int
getDimY()
private String
Return the shortcut key as a String.getName()
boolean
void
mouseClicked
(MouseEvent event) void
mouseEntered
(MouseEvent event) void
mouseExited
(MouseEvent event) void
mousePressed
(MouseEvent event) void
mouseReleased
(MouseEvent event) void
Draw border.void
To draw component.void
setActionB
(int x) void
setBordure
(boolean b) void
setBounds
(int x, int y, int width, int heigth) Overrided setter to update if button should be selected.void
setCFondUseAlpha
(boolean b) void
setColor
(int x) void
Swap color between green & yellow.void
setEnabled
(boolean b) void
setIsYellow
(boolean b) void
setLocation
(int x, int y) Overrided setter to update if button should be selected.void
void
setSelected
(boolean selected) Set the button selected or not.void
setSelected
(boolean selected, boolean mouseLocated) set the button selected or not.void
setSize
(int size) void
setSize
(int width, int heigth) Overrided setter to update if button should be selected.void
setVisible
(boolean visible) Overrided setter to update if button should be selected.void
setWithBackground
(boolean b) protected void
Update the border color.void
Set the button selected or not depending of mouse x,y.Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
id
protected final int id -
cpt
protected static int cpt -
img
-
nom
-
p
-
action
protected int action -
bordure
protected boolean bordure -
cFondUseAlpha
protected boolean cFondUseAlpha -
withBackground
protected boolean withBackground -
color
protected int color -
isYellow
protected boolean isYellow -
drawOnlySelectedBorder
protected boolean drawOnlySelectedBorder
-
-
Constructor Details
-
FButton
Create a new FButton.- Parameters:
name
- the name of the buttonp
- panel that contain thisaction
- action to do. -2 = no action to do.imag
- image to represent the button
-
FButton
Create a new FButton without image.- Parameters:
name
- the name of the buttonp
- panel that contain thisaction
- action to do. -2 = no action to do.
-
-
Method Details
-
getName
-
setNom
-
getActionB
public int getActionB() -
setActionB
public void setActionB(int x) -
setBordure
public void setBordure(boolean b) -
getDimY
public static int getDimY() -
setCFondUseAlpha
public void setCFondUseAlpha(boolean b) -
getBackgroundColor
return background color with or without alpha. With alpha if cFondUseAlpha==True; -
getCFont
-
getWithBackground
public boolean getWithBackground() -
setWithBackground
public void setWithBackground(boolean b) -
getFBorder
-
setSize
public void setSize(int size) -
setColor
public void setColor(int x) -
setDefaultColor
public void setDefaultColor()Swap color between green & yellow. -
setIsYellow
public void setIsYellow(boolean b) -
setSize
public void setSize(int width, int heigth) Overrided setter to update if button should be selected.
If size, location or visibility have been change, button many need to be set as selected or not. -
setLocation
public void setLocation(int x, int y) Overrided setter to update if button should be selected.
If size, location or visibility have been change, button many need to be set as selected or not.- Overrides:
setLocation
in classComponent
-
setBounds
public void setBounds(int x, int y, int width, int heigth) Overrided setter to update if button should be selected.
If size, location or visibility have been change, button many need to be set as selected or not. -
setVisible
public void setVisible(boolean visible) Overrided setter to update if button should be selected.
If size, location or visibility have been change, button many need to be set as selected or not.- Overrides:
setVisible
in classJComponent
-
paintComponent
To draw component.
It draw a fill rectangle as background color. Draw it there alow to have alpha color.- Overrides:
paintComponent
in classJComponent
-
updateBorderColor
protected void updateBorderColor()Update the border color. -
paintBorder
Draw border. -
setEnabled
public void setEnabled(boolean b) - Overrides:
setEnabled
in classAbstractButton
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
updateSelected
public void updateSelected()Set the button selected or not depending of mouse x,y.
To compare it to mouse x, y we use x,y of the button relative to screen. -
setSelected
public void setSelected(boolean selected, boolean mouseLocated) set the button selected or not.- Parameters:
selected
- true if button is selectedmouseLocated
- true if desc is mouse located
-
setSelected
public void setSelected(boolean selected) Set the button selected or not.
By default desc is not mouse located.- Overrides:
setSelected
in classAbstractButton
- Parameters:
selected
- true if button is selected
-
getKeyboardKey
Return the shortcut key as a String.
If key don't exist it will return an empty String. -
getDesc
Return the description of the button.
-