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.AccessibleJButtonNested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListenerNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanprotected booleanprotected intprotected static intprotected booleanprotected final intprotected Imageprotected booleanprotected Stringprotected FPanelprotected booleanFields 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_PROPERTYFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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 TypeMethodDescriptionintreturn background color with or without alpha.getCFont()protected StringgetDesc()Return the description of the button.static intgetDimY()private StringReturn the shortcut key as a String.getName()booleanvoidmouseClicked(MouseEvent event) voidmouseEntered(MouseEvent event) voidmouseExited(MouseEvent event) voidmousePressed(MouseEvent event) voidmouseReleased(MouseEvent event) voidDraw border.voidTo draw component.voidsetActionB(int x) voidsetBordure(boolean b) voidsetBounds(int x, int y, int width, int heigth) Overrided setter to update if button should be selected.voidsetCFondUseAlpha(boolean b) voidsetColor(int x) voidSwap color between green & yellow.voidsetEnabled(boolean b) voidsetIsYellow(boolean b) voidsetLocation(int x, int y) Overrided setter to update if button should be selected.voidvoidsetSelected(boolean selected) Set the button selected or not.voidsetSelected(boolean selected, boolean mouseLocated) set the button selected or not.voidsetSize(int size) voidsetSize(int width, int heigth) Overrided setter to update if button should be selected.voidsetVisible(boolean visible) Overrided setter to update if button should be selected.voidsetWithBackground(boolean b) protected voidUpdate the border color.voidSet the button selected or not depending of mouse x,y.Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUIMethods 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, setVerticalTextPositionMethods 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, updateMethods 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, validateTreeMethods 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:
 setLocationin 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:
 setVisiblein classJComponent
 - 
paintComponent
To draw component.
It draw a fill rectangle as background color. Draw it there alow to have alpha color.- Overrides:
 paintComponentin classJComponent
 - 
updateBorderColor
protected void updateBorderColor()Update the border color. - 
paintBorder
Draw border. - 
setEnabled
public void setEnabled(boolean b) - Overrides:
 setEnabledin classAbstractButton
 - 
mouseClicked
- Specified by:
 mouseClickedin interfaceMouseListener
 - 
mouseEntered
- Specified by:
 mouseEnteredin interfaceMouseListener
 - 
mouseExited
- Specified by:
 mouseExitedin interfaceMouseListener
 - 
mousePressed
- Specified by:
 mousePressedin interfaceMouseListener
 - 
mouseReleased
- Specified by:
 mouseReleasedin 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:
 setSelectedin 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. 
 -