Sharkysoft home

lava.gui
Class JImagePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--lava.gui.JImagePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JImagePanel
extends javax.swing.JPanel

JPanel with background image.

Details: A JImagePanel is a JPanel that displays a single background image. The image can be centered (default) or flush against the canvas' sides or corners, or stretched horizontally and/or vertically to span the entire canvas. JImagePanel supports animated images, such as GIFs.

Since:
1998.04.28
Version:
2000.02.22
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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  int alignment
          Image alignment.
protected  java.awt.Image image
          The Image displayed in this Canvas.
protected  java.awt.Point position
          Image position.
protected  java.awt.Dimension size
          Image size.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JImagePanel(java.awt.Dimension dim, java.awt.Image image)
          Initializes this JImagePanel to have the given dimension and image content.
JImagePanel(java.awt.Dimension dim, java.awt.Image image, int alignment)
          Initializes this JImagePanel to have the given dimension and image content.
JImagePanel(java.awt.Image image)
          Initializes with image.
 
Method Summary
 java.awt.Image getImage()
          Returns the current image.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Progressively renders image.
 void paintComponent(java.awt.Graphics g)
          Draws this Canvas using the specified Graphics object.
 void reshape(int x, int y, int w, int h)
          Changes bounds (deprecated).
 void setImage(java.awt.Image image)
          Sets the image to be displayed in this Canvas.
 void setImageAlignment(int new_alignment)
          Changes the image alignment.
 void setImagePosition(java.awt.Point p)
          Moves the image.
 void setImageSize(java.awt.Dimension d)
          Sets image size.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
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, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, 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

image

protected java.awt.Image image
The Image displayed in this Canvas.

alignment

protected int alignment
Image alignment.

Details: This member indicates the current alignment, as set during construction or in calls to setImageAlignment.

Default value: CENTER

Since:
1998.10.06

position

protected java.awt.Point position
Image position.

Details: position is the location, in the Canvas, of the upper-left corner of the image. The value of position is updated by calls to setImage, setImageAlignment, and setImagePosition.

Since:
1999.04.20

size

protected java.awt.Dimension size
Image size.

Details: size is the display size of this JImagePanel' image. size may be different from the image's natural size if the JImagePanel is set to display a stretched image. A null value indicates that the image is to be rendered at its natural size, without stretching. Because of this, settting size to null results in more efficient image rendering.

Since:
1999.04.20
Constructor Detail

JImagePanel

public JImagePanel(java.awt.Image image)
Initializes with image.

Details: This constructor sets the current image and sets the canvas size to be the same as the image. This constructor will not return until the image's dimensions have been determined, and will fail if the dimensions cannot be determined.

Parameters:
image - the image
Since:
1999.04.21

JImagePanel

public JImagePanel(java.awt.Dimension dim,
                   java.awt.Image image)
Initializes this JImagePanel to have the given dimension and image content. A null image indicates that no image is to be displayed (yet). The image can be changed by calling setImage.
Parameters:
dim - the minimum size of this Canvas
image - the image currently displayed in this canvas

JImagePanel

public JImagePanel(java.awt.Dimension dim,
                   java.awt.Image image,
                   int alignment)
Initializes this JImagePanel to have the given dimension and image content. A null image indicates that no image is to be displayed (yet). This image can be changed by calling setImage.
Parameters:
dim - the minimum size of this Canvas
image - the image currently displayed in this canvas
Method Detail

setImage

public void setImage(java.awt.Image image)
Sets the image to be displayed in this Canvas. Specifying a null image is legal and results in no image being displayed at all.
Parameters:
image - the new image

getImage

public java.awt.Image getImage()
Returns the current image.
Returns:
the current image
Since:
1998.10.10

paintComponent

public void paintComponent(java.awt.Graphics g)
Draws this Canvas using the specified Graphics object. Called by the AWT subsystem.
Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics object

setImageAlignment

public void setImageAlignment(int new_alignment)
Changes the image alignment.

Details: setImageAlignment changes the alignment of the image displayed in the canvas. new_alignment may be Alignment.NORTH, Alignment.SOUTH, Alignment.EAST, Alignment.WEST, or any sensible combination of these constants. (Combinations are formed by OR-ing.)

setImageAlignment preserves the image's current display size unless the new alignment requires stretching the image to a new size.

Parameters:
new_alignment - the new alignment setting
Since:
1998.10.06

setImagePosition

public void setImagePosition(java.awt.Point p)
Moves the image.

Details: setImagePosition moves the image so that its upper-left corner is the pixel at canvas coordinate p.

Parameters:
p - the new position
Since:
1999.04.20

setImageSize

public void setImageSize(java.awt.Dimension d)
Sets image size.

Details: setImageSize sets the display dimensions of the image. Normally, this method should only be called when the intent is to stretch or shrink the image from its normal size. If d is null, the image will be displayed at its natural size.

Parameters:
d - the new image size
Since:
1999.04.20

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Progressively renders image.

Details: imageUpdate responds to progressively available image data. This method is used internally and should not be called by user threads.

Overrides:
imageUpdate in class java.awt.Component
Since:
1999.04.20

reshape

public void reshape(int x,
                    int y,
                    int w,
                    int h)
Changes bounds (deprecated).

Details: Whether you call setBounds, setSize, resize, or what-have-you, Component.reshape is the method ultimately called by the AWT whenever a component's dimensions are changed. Nevertheless, the retards at Sun deprecated reshape by introducing a setBounds method, whose implementation does nothing but forward the parameters to reshape anyway. Thus, in order to augment resizing behavior, ImageCanvas must override reshape, even though it is deprecated. Don't forget, however, that reshape is still considered to be a deprecated method name and therefore this method should never be called (unless you work for Sun). Use setBounds instead.

Overrides:
reshape in class javax.swing.JComponent
Since:
2000.02.23

Sharkysoft home