|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--lava.gui.JImagePanel
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.
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 |
protected java.awt.Image image
Image
displayed in this Canvas
.protected int alignment
Details: This member indicates the current alignment, as set during construction or in calls to setImageAlignment
.
Default value: CENTER
protected java.awt.Point 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.
protected java.awt.Dimension 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.
Constructor Detail |
public JImagePanel(java.awt.Image 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.
image
- the imagepublic JImagePanel(java.awt.Dimension dim, java.awt.Image image)
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
.dim
- the minimum size of this Canvasimage
- the image currently displayed in this canvaspublic JImagePanel(java.awt.Dimension dim, java.awt.Image image, int alignment)
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
.dim
- the minimum size of this Canvasimage
- the image currently displayed in this canvasMethod Detail |
public void setImage(java.awt.Image image)
image
- the new imagepublic java.awt.Image getImage()
public void paintComponent(java.awt.Graphics g)
Canvas
using the specified Graphics
object. Called by the AWT subsystem.paintComponent
in class javax.swing.JComponent
g
- the graphics objectpublic void setImageAlignment(int new_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.
new_alignment
- the new alignment settingpublic void setImagePosition(java.awt.Point p)
Details: setImagePosition moves the image so that its upper-left corner is the pixel at canvas coordinate p.
p
- the new positionpublic void setImageSize(java.awt.Dimension d)
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.
d
- the new image sizepublic boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
Details: imageUpdate responds to progressively available image data. This method is used internally and should not be called by user threads.
imageUpdate
in class java.awt.Component
public void reshape(int x, int y, int w, int h)
Details: Whether you call setBounds
, setSize
, resize
, or what-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.
reshape
in class javax.swing.JComponent
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |