public class InventoryImagePanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
| Modifier and Type | Class and Description |
|---|---|
class |
InventoryImagePanel.SlotPos
An inner class of the InventoryPanel class which represents the slots of the shop panel
|
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static int |
COL_SIZE
The number of columns in the inventory panel
|
MoveInvItemInfo |
dstSlot
The destination slot when moving an item
|
static int |
H
The height of the inventory panel with the Use button
|
java.awt.image.BufferedImage |
image
Stores the inventory panel image
|
static java.lang.String |
IMAGE_FILENAME
The filename of the inventory panel image
|
java.lang.String |
imageFilename
Stores the filename of the inventory panel image
|
static int |
INV_H
The height of the inventory panel
|
static int |
mouseX
Stores the x position of the user's mouse's cursor while the inventory panel is on
|
static int |
mouseY
Stores the y position of the user's mouse's cursor while the inventory panel is on
|
static int |
ROW_SIZE
The number of rows in the inventory panel
|
static int |
SLOT_GAP_H
The y distance from 1 slot to another
|
static int |
SLOT_GAP_W
The x distance from 1 slot to another
|
static int |
SLOT_H
The height of a slot
|
static int |
SLOT_W
The width of a slot
|
static Item[][] |
slots
Stores the items in the inventory
|
MoveInvItemInfo |
srcSlot
The source slot when moving an item
|
static int |
START_SLOT_X
The x position of the first slot in the inventory panel
|
static int |
START_SLOT_Y
The y position of the first slot in the inventory panel
|
static boolean |
TURN_ON
The starting flag indicating whether the inventory panel is on or off
|
static boolean |
turnOn
Identifies if the inventory panel is on/off
|
static int |
W
The width of the inventory panel
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
InventoryImagePanel()
The default constructor used to create the inventory panel
|
| Modifier and Type | Method and Description |
|---|---|
InventoryImagePanel.SlotPos |
getSlotPos(int x,
int y)
Gets the slot that was clicked on by the player
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed AND released
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed and then the mouse moves
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component
|
void |
mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse moves
|
void |
mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released after being pressed
|
void |
moveItems(InventoryImagePanel.SlotPos slotPos)
Handles items being moved from one inventory slot to another
|
void |
myPaint(java.awt.Graphics g)
Draws the inventory panel and the items in the inventory
|
void |
paint(java.awt.Graphics g)
An empty body function but used to remove the blinking effect of the inventory panel when moved
|
void |
updateInvItems()
Updates items in the inventory panel when items have been added/removed
|
void |
useItem()
Invokes the selected item's feature and applies it onto Sonic
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, paintBorder, paintChildren, paintComponent, 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, updateadd, 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, transferFocusDownCycle, validate, validateTreeaction, 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, imageUpdate, 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, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final boolean TURN_ON
public static final java.lang.String IMAGE_FILENAME
public static final int W
public static final int INV_H
public static final int H
public static final int ROW_SIZE
public static final int COL_SIZE
public static final int START_SLOT_X
public static final int START_SLOT_Y
public static final int SLOT_GAP_W
public static final int SLOT_GAP_H
public static final int SLOT_W
public static final int SLOT_H
public static boolean turnOn
public static int mouseX
public static int mouseY
public java.lang.String imageFilename
public java.awt.image.BufferedImage image
public static Item[][] slots
public MoveInvItemInfo srcSlot
public MoveInvItemInfo dstSlot
public InventoryImagePanel()
public InventoryImagePanel.SlotPos getSlotPos(int x, int y)
x - The x-coordinate that was clicked on by the mouse of the playery - The y-coordinate that was clicked on by the mouse of the playerpublic void paint(java.awt.Graphics g)
paint in class javax.swing.JComponentpublic void myPaint(java.awt.Graphics g)
g - An instance of the Graphics objectpublic void updateInvItems()
public void useItem()
public void moveItems(InventoryImagePanel.SlotPos slotPos)
slotPos - The destination slotpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenere - Provided by Java and represents the mouse eventpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenere - Provided by Java and represents the mouse eventpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenere - Provided by Java and represents the mouse eventpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenere - Provided by Java and represents the mouse eventpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenere - Provided by Java and represents the mouse eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenere - Provided by Java and represents the mouse eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenere - Provided by Java and represents the mouse event