mdh.hephaestus2.gamelib
Class IconList

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--mdh.hephaestus2.gamelib.DoublePanel
                          |
                          +--mdh.hephaestus2.gamelib.IconList
All Implemented Interfaces:
Accessible, AdjustmentListener, EventListener, ImageObserver, ItemSelectable, KeyListener, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class IconList
extends DoublePanel
implements ItemSelectable, AdjustmentListener, KeyListener, MouseListener, MouseMotionListener

A scrolling list with an icon and a hotkey for each entry. Unlike java.awt.List, only one item can be selected, and one item is always selected. Only generates ItemEvents for selecting items.

Author:
Copyright © 2001 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IconList()
          calls IconList(8)
IconList(int cellsVisible)
           
 
Method Summary
 void add(Image icon, int key, String text)
          Adds a new line at the end of the list.
 void add(String text)
           
 void addActionListener(ActionListener al)
           
 void addItemListener(ItemListener il)
           
 void addNotify()
           
 void adjustmentValueChanged(AdjustmentEvent ae)
          Messages from the scrollbar
 void beginAtomic()
          Call beginAtomic() just before you want to make a whole bunch of changes, and it won't repaint or resize until you call endAtomic(); this can speed many operations up a few thousand times.
 void click(int cell)
           
 void draw(Graphics2D g)
          Override this to do your drawing on the offscreen buffer; you need do nothing else.
 void endAtomic()
          Don't forget to endAtomic() after making your changes, or it will never repaint again.
 String getItem(int i)
           
 int getItemCount()
           
 Dimension getMaximumSize()
           
 Dimension getMinimumSize()
           
 Dimension getPreferredSize()
           
 int getRows()
           
 int getScaleIcons()
           
 int getSelectedIndex()
           
 String getSelectedItem()
           
 Object[] getSelectedObjects()
           
 int getVisibleIndex()
           
 boolean isFocusable()
           
 boolean isFocusTraversable()
          This is deprecated in 1.4, but still necessary for 1.3 compatibility.
 void keyPressed(KeyEvent ke)
           
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
           
 int length()
           
static void main(String[] args)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void removeActionListener(ActionListener al)
           
 void removeAll()
          Removes all lines from the list.
 void removeItemListener(ItemListener il)
           
 void resize()
          Internal calculations for size.
 void select(int cell)
           
 void setCellsVisible(int n)
          Sets the number of cells visible.
 void setScaleIcons(int s)
           
 void setTopCell(int t)
          Sets the topmost visible cell.
 String toString()
           
 
Methods inherited from class mdh.hephaestus2.gamelib.DoublePanel
isDoubleBuffered, isFixedSize, paint, redraw, repaintNow, setSize, update
 
Methods inherited from class java.awt.Panel
getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IconList

public IconList(int cellsVisible)

IconList

public IconList()
calls IconList(8)

Method Detail

main

public static void main(String[] args)

add

public void add(String text)

add

public void add(Image icon,
                int key,
                String text)
Adds a new line at the end of the list.


addActionListener

public void addActionListener(ActionListener al)

addItemListener

public void addItemListener(ItemListener il)
Specified by:
addItemListener in interface ItemSelectable

addNotify

public void addNotify()
Overrides:
addNotify in class Panel

adjustmentValueChanged

public void adjustmentValueChanged(AdjustmentEvent ae)
Messages from the scrollbar

Specified by:
adjustmentValueChanged in interface AdjustmentListener

beginAtomic

public void beginAtomic()
Call beginAtomic() just before you want to make a whole bunch of changes, and it won't repaint or resize until you call endAtomic(); this can speed many operations up a few thousand times.


click

public void click(int cell)

draw

public void draw(Graphics2D g)
Description copied from class: DoublePanel
Override this to do your drawing on the offscreen buffer; you need do nothing else.

Specified by:
draw in class DoublePanel

endAtomic

public void endAtomic()
Don't forget to endAtomic() after making your changes, or it will never repaint again.


getItem

public String getItem(int i)

getItemCount

public int getItemCount()

getMaximumSize

public Dimension getMaximumSize()
Overrides:
getMaximumSize in class Container

getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class DoublePanel

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class DoublePanel

getRows

public int getRows()
Returns:
the number of cells visible at once.

getScaleIcons

public int getScaleIcons()

getSelectedIndex

public int getSelectedIndex()

getSelectedItem

public String getSelectedItem()

getSelectedObjects

public Object[] getSelectedObjects()
Specified by:
getSelectedObjects in interface ItemSelectable

getVisibleIndex

public int getVisibleIndex()
Returns:
the topmost visible cell.

isFocusable

public boolean isFocusable()
Overrides:
isFocusable in class DoublePanel

isFocusTraversable

public boolean isFocusTraversable()
Description copied from class: DoublePanel
This is deprecated in 1.4, but still necessary for 1.3 compatibility.

Overrides:
isFocusTraversable in class DoublePanel

keyReleased

public void keyReleased(KeyEvent ke)
Specified by:
keyReleased in interface KeyListener

keyPressed

public void keyPressed(KeyEvent ke)
Specified by:
keyPressed in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ke)
Specified by:
keyTyped in interface KeyListener

length

public int length()
Returns:
the number of lines in the list.

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

removeAll

public void removeAll()
Removes all lines from the list.

Overrides:
removeAll in class Container

resize

public void resize()
Internal calculations for size. Call instead of repaint() or rescroll() when contents, cellWidth, cellHeight, or cellsVisible change.


removeActionListener

public void removeActionListener(ActionListener al)

removeItemListener

public void removeItemListener(ItemListener il)
Specified by:
removeItemListener in interface ItemSelectable

select

public void select(int cell)

setCellsVisible

public void setCellsVisible(int n)
Sets the number of cells visible.


setScaleIcons

public void setScaleIcons(int s)

setTopCell

public void setTopCell(int t)
Sets the topmost visible cell.


toString

public String toString()
Overrides:
toString in class Component