Class FButton

All Implemented Interfaces:
MouseListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants
Direct Known Subclasses:
BoutonLong, FButtonLink, FButtonPGO, FPanelMiniMapContainer.FButtonEndTurn

public class FButton extends JButton implements MouseListener
Extends of Button with some added functions.
There is a default color for normal button, focus button & disable button.
Defaults colors are in Data.
Author:
Hydrolien
See Also:
  • Field Details

    • id

      protected final int id
    • cpt

      protected static int cpt
    • img

      protected Image img
    • nom

      protected String nom
    • p

      protected FPanel 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

      public FButton(String name, FPanel p, int action, Image imag)
      Create a new FButton.
      Parameters:
      name - the name of the button
      p - panel that contain this
      action - action to do. -2 = no action to do.
      imag - image to represent the button
    • FButton

      public FButton(String name, FPanel p, int action)
      Create a new FButton without image.
      Parameters:
      name - the name of the button
      p - panel that contain this
      action - action to do. -2 = no action to do.
  • Method Details

    • getName

      public String getName()
      Overrides:
      getName in class Component
    • setNom

      public void setNom(String s)
    • 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

      public Color getBackgroundColor()
      return background color with or without alpha. With alpha if cFondUseAlpha==True;
    • getCFont

      public Color getCFont()
    • getWithBackground

      public boolean getWithBackground()
    • setWithBackground

      public void setWithBackground(boolean b)
    • getFBorder

      public FBorder 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.
      Overrides:
      setSize in class Component
    • 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 class Component
    • 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.
      Overrides:
      setBounds in class Component
    • 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 class JComponent
    • paintComponent

      public void paintComponent(Graphics g)
      To draw component.
      It draw a fill rectangle as background color. Draw it there alow to have alpha color.
      Overrides:
      paintComponent in class JComponent
    • updateBorderColor

      protected void updateBorderColor()
      Update the border color.
    • paintBorder

      public void paintBorder(Graphics2D g)
      Draw border.
    • setEnabled

      public void setEnabled(boolean b)
      Overrides:
      setEnabled in class AbstractButton
    • mouseClicked

      public void mouseClicked(MouseEvent event)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent event)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent event)
      Specified by:
      mouseExited in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent event)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent event)
      Specified by:
      mouseReleased in interface MouseListener
    • 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 selected
      mouseLocated - 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 class AbstractButton
      Parameters:
      selected - true if button is selected
    • getKeyboardKey

      private String getKeyboardKey()
      Return the shortcut key as a String.
      If key don't exist it will return an empty String.
    • getDesc

      protected String getDesc()
      Return the description of the button.