de.kosi.gui.view.game
Class CardComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.AbstractButton
                          |
                          +--javax.swing.JButton
                                |
                                +--de.kosi.gui.view.game.CardComponent
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, ResourceBundleChangeListener, java.io.Serializable, javax.swing.SwingConstants

public class CardComponent
extends javax.swing.JButton
implements ResourceBundleChangeListener

The graphical representation of a card.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JButton
javax.swing.JButton.AccessibleJButton
 
Inner classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  CCard card
          The card shown by this component.
 int cardHandCount
          Layout information.
 int cardHandIndex
          Layout information.
 int cardSuitCount
          Layout information.
 int cardSuitIndex
          Layout information.
protected  boolean focus
          A flag indicating whether this card component has the focus or not.
 int layer
          Layout information.
protected  int orientation
          The orientation of this component.
protected  boolean pressed
          A flag indicating whether this card component is pressed or not.
protected  boolean rollover
          A flag indicating whether this card component in roll over state or not.
 int suitCount
          Layout information.
 int suitIndex
          Layout information.
 
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
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, 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
CardComponent()
          Creates a new card component.
 
Method Summary
 void focusGained(java.awt.event.FocusEvent event)
          Informs this component that it received the focus.
 void focusLost(java.awt.event.FocusEvent event)
          Informs this component that it lost the focus.
 CCard getCard()
          Gets the card this component shows.
 int getOrientation()
          Returns the orientation of the card component.
 int getSuit()
          Gets this card components suit.
 int getValue()
          Gets this card components value.
 boolean hasFocus()
          Returns true if this component has got the focus.
 boolean isPressed()
          Gets the pressed state of this card component.
 boolean isRollover()
          Gets the highlit state of this card component.
 void paintComponent(java.awt.Graphics graphics)
          Paints this component.
 void resourceBundleChanged(CResourceBundle resourceBundle)
          Informs this card component that the resource bundle has been changed.
 void setCard(CCard card)
          Sets the card which this component displays.
 void setEnabled(boolean enabled)
          Disables or enabled this component.
static void setEnabled(java.util.Collection cardComponents, boolean enabled)
          Sets the enabled state of all cards in the specified collection to the given enabled state.
 void setFocus(boolean focus)
          Sets this components focus flag.
 void setOrientation(int orientation)
          Sets the orientation of the card component.
 void setPressed(boolean pressed)
          Sets this components pressed state.
 void setRollover(boolean rollover)
          Sets this components roll over state.
static void setVisible(java.util.Collection cardComponents, boolean visible)
          Shows or hides the specified card components.
 
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getDisabledIcon, getDisabledSelectedIcon, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getLabel, getMargin, getMnemonic, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isFocusTraversable, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
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, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

card

protected CCard card
The card shown by this component.

orientation

protected int orientation
The orientation of this component.

cardHandIndex

public int cardHandIndex
Layout information.

cardHandCount

public int cardHandCount
Layout information.

cardSuitIndex

public int cardSuitIndex
Layout information.

cardSuitCount

public int cardSuitCount
Layout information.

suitCount

public int suitCount
Layout information.

suitIndex

public int suitIndex
Layout information.

layer

public int layer
Layout information.

focus

protected boolean focus
A flag indicating whether this card component has the focus or not.

pressed

protected boolean pressed
A flag indicating whether this card component is pressed or not.

rollover

protected boolean rollover
A flag indicating whether this card component in roll over state or not.
Constructor Detail

CardComponent

public CardComponent()
Creates a new card component.
Method Detail

resourceBundleChanged

public void resourceBundleChanged(CResourceBundle resourceBundle)
Informs this card component that the resource bundle has been changed.
Specified by:
resourceBundleChanged in interface ResourceBundleChangeListener
Parameters:
resourceBundle - the new resource bundle.

setCard

public void setCard(CCard card)
Sets the card which this component displays. Warning: an argument of null is not allowed. Use CCard.getBack() instead, which tells this component to show the back side of a card.
Parameters:
card - the card to display.

getCard

public CCard getCard()
Gets the card this component shows.
Returns:
the card field.

getSuit

public int getSuit()
Gets this card components suit.
Returns:
the suit of the card.

getValue

public int getValue()
Gets this card components value.
Returns:
the value of the card.

setOrientation

public void setOrientation(int orientation)
Sets the orientation of the card component.
Parameters:
orientation - one of CConstants.ORIENTATION_TOP, CConstants.ORIENTATION_RIGHT, ...

getOrientation

public int getOrientation()
Returns the orientation of the card component.
Returns:
one of the CConstants.ORIENTATION_X constants.

paintComponent

public void paintComponent(java.awt.Graphics graphics)
Paints this component.
Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
graphics - the graphics context.

focusGained

public void focusGained(java.awt.event.FocusEvent event)
Informs this component that it received the focus.
Parameters:
event - the event that caused the focus change.

focusLost

public void focusLost(java.awt.event.FocusEvent event)
Informs this component that it lost the focus.
Parameters:
event - the event that caused the focus change.

setEnabled

public void setEnabled(boolean enabled)
Disables or enabled this component.
Overrides:
setEnabled in class javax.swing.AbstractButton
Parameters:
enabled - if true this component becomes enabled.

setPressed

public void setPressed(boolean pressed)
Sets this components pressed state.
Parameters:
pressed - the new pressed state.

setRollover

public void setRollover(boolean rollover)
Sets this components roll over state.
Parameters:
rollover - the new roll over state.

setFocus

public void setFocus(boolean focus)
Sets this components focus flag.
Parameters:
focus - the new focus state.

isRollover

public boolean isRollover()
Gets the highlit state of this card component.
Returns:
true if this card component is in roll over state.

isPressed

public boolean isPressed()
Gets the pressed state of this card component.
Returns:
true if this card component is pressed.

hasFocus

public boolean hasFocus()
Returns true if this component has got the focus.
Overrides:
hasFocus in class javax.swing.JComponent
Returns:
true if this component has got the focus.

setEnabled

public static void setEnabled(java.util.Collection cardComponents,
                              boolean enabled)
Sets the enabled state of all cards in the specified collection to the given enabled state.
Parameters:
cardComponents - the card components to set the enabled state of.
enabled - the enabled state all card components become set to.

setVisible

public static void setVisible(java.util.Collection cardComponents,
                              boolean visible)
Shows or hides the specified card components.
Parameters:
cardComponents - the card components.
visible - the new visible state of the card components.