|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
edu.gvsu.GVcard
public class GVcard
This is an abstraction of a single card. This class is implemented as a subclass of JLabel. You are unlikely to use this class directly for the project. Use the Pile class instead. Use the getValue() method to get the integer value of a card (Ace=14, King=13, Queen=12, Jack=11). Use the getSuit() method to get the integer representation of the suit (Diamond=0, Heart=1, Spade=2, Club=3). If you need to obtain the String name of the suit, use the getSuitName() method.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JLabel |
|---|
javax.swing.JLabel.AccessibleJLabel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
ACE
constant definition for Ace |
static int |
CLUB
constant definition for Club |
static int |
DIAMOND
constant definition for Diamond |
static int |
HEART
constant definition for Heart |
static int |
JACK
constant definition for Jack |
static int |
KING
constant definition for King |
static int |
QUEEN
constant definition for Queen |
static int |
SPADE
constant definition for Spade |
| Fields inherited from class javax.swing.JLabel |
|---|
labelFor |
| 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, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, 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 | |
|---|---|
GVcard(int value,
int suit,
javax.swing.ImageIcon img)
Constructor, similar to the previous constructor but the front face image is an Icon object. |
|
GVcard(int value,
int suit,
java.lang.String img_file)
Constructor. |
|
| Method Summary | |
|---|---|
void |
faceDown()
Make the card to face down |
void |
faceUp()
Make the card to face up |
void |
flip()
Flip the card |
static int |
getCardHeight()
Returns the height of a card |
static int |
getCardWidth()
Returns the width of a card |
java.awt.Dimension |
getMaximumSize()
Override the method in the parent class |
java.awt.Dimension |
getMinimumSize()
Override the method in the parent class |
java.awt.Dimension |
getPreferredSize()
Override the method in the parent class |
int |
getSuit()
Get the suit of the card |
java.lang.String |
getSuitName()
Get the name of the suit |
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor f)
|
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors()
|
int |
getValue()
Get the numerical value of the card |
boolean |
isBlack()
Check if the card is from a black suit (CLUB or SPADE) |
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor f)
|
boolean |
isDown()
Check if the card is facing down |
boolean |
isMarked()
Check if the card has been marked |
boolean |
isRed()
Check if the card is from a red suit (DIAMOND or HEART) |
boolean |
isUp()
Check if the card is facing up |
void |
mark()
Mark the card by changing its front face to a "grayscale" image |
void |
paintComponent(java.awt.Graphics g)
Override the paintComponent() method |
static void |
setBackFace(java.lang.String img_file)
Set the image (PNG, JPEG, GIF) image of the back of the card |
java.lang.String |
toString()
Override the method in the parent class |
void |
unMark()
Unmark the card by restoring its front face image |
| Methods inherited from class javax.swing.JLabel |
|---|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI |
| 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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, 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, setLayout, transferFocusBackward, 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, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int JACK
public static final int QUEEN
public static final int KING
public static final int ACE
public static final int DIAMOND
public static final int HEART
public static final int SPADE
public static final int CLUB
| Constructor Detail |
|---|
public GVcard(int value,
int suit,
java.lang.String img_file)
value - integer value of the card (2, 3, ..., 10, JACK, ..., ACE .suit - integer value representing the suit of the card (HEART,
SPADE, CLUB, DIAMOND).img_file - a JPEG or GIF image to be used for the front face
of the card.
public GVcard(int value,
int suit,
javax.swing.ImageIcon img)
value - integer value of the card (2, 3, ..., 10, JACK, ..., ACE .suit - integer value representing the suit of the card (HEART,
SPADE, CLUB, DIAMOND).img - an ImageIcon containing the front face of the card.| Method Detail |
|---|
public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentg - graphics contextpublic static void setBackFace(java.lang.String img_file)
img_file - a JPEG or GIF image to be used for the front face
of the card.public static int getCardWidth()
public static int getCardHeight()
public void mark()
public void unMark()
public boolean isMarked()
public boolean isUp()
public boolean isDown()
public boolean isRed()
public boolean isBlack()
public int getValue()
public int getSuit()
public java.lang.String getSuitName()
public void faceUp()
public void faceDown()
public void flip()
public java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JComponentpublic java.awt.Dimension getMinimumSize()
getMinimumSize in class javax.swing.JComponentpublic java.awt.Dimension getMaximumSize()
getMaximumSize in class javax.swing.JComponentpublic java.lang.String toString()
toString in class java.awt.Componentpublic java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor f)
throws java.awt.datatransfer.UnsupportedFlavorException
getTransferData in interface java.awt.datatransfer.Transferablejava.awt.datatransfer.UnsupportedFlavorExceptionpublic boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor f)
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||