org.openswing.swing.client
Class ImagePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.openswing.swing.client.ImagePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ImagePanel
extends javax.swing.JPanel

Title: OpenSwing Framework

Description: Panel based on a JScrollPane that can shows an image. Image can be retrieved by "images" subfolder, by specifying and image name or by passing a byte[] argument.

Copyright: Copyright (C) 2006 Mauro Carniel

This file is part of OpenSwing Framework. This library is free software; you can redistribute it and/or modify it under the terms of the (LGPL) Lesser General Public License as published by the Free Software Foundation; GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be contacted at: maurocarniel@tin.it

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int SCROLLBAR_ALWAYS
           
static int SCROLLBAR_AS_NEEDED
           
static int SCROLLBAR_NEVER
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
ImagePanel()
           
 
Method Summary
 void addMouseListener(java.awt.event.MouseListener listener)
           
 byte[] getImage()
          Set the image from a byte[].
 int getImageHeight()
           
 java.lang.String getImageName()
          Set the image from a file name.
 int getImageWidth()
           
 int getScrollBarsPolicy()
           
 java.lang.String getToolTipText()
           
 void removeMouseListener(java.awt.event.MouseListener listener)
           
 void setImage(byte[] image)
          Set the image from a byte[].
 void setImage(java.awt.Image image)
          Set the image.
 void setImageAsStream(java.io.InputStream in)
          Set the image from an InputStream.
 void setImageName(java.lang.String imageName)
          Set the image from a file name.
 void setScrollBarsPolicy(int policy)
          Determines when the scrollbars appears in the scrollpane.
 void setToolTipText(java.lang.String toolTipText)
          Set a tooltip text.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, 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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCROLLBAR_AS_NEEDED

public static final int SCROLLBAR_AS_NEEDED
See Also:
Constant Field Values

SCROLLBAR_NEVER

public static final int SCROLLBAR_NEVER
See Also:
Constant Field Values

SCROLLBAR_ALWAYS

public static final int SCROLLBAR_ALWAYS
See Also:
Constant Field Values
Constructor Detail

ImagePanel

public ImagePanel()
Method Detail

getImageHeight

public final int getImageHeight()
Returns:
image height

getImageWidth

public final int getImageWidth()
Returns:
image width

setImage

public final void setImage(byte[] image)
Set the image from a byte[].

Parameters:
image - image to set

setImage

public final void setImage(java.awt.Image image)
Set the image.

Parameters:
image - image to set

setImageAsStream

public final void setImageAsStream(java.io.InputStream in)
                            throws java.io.IOException
Set the image from an InputStream. The InputStream will be automatically close after reading it.

Parameters:
in - image to set, expressed as an InputStream
Throws:
java.io.IOException

getImage

public final byte[] getImage()
Set the image from a byte[].


setImageName

public final void setImageName(java.lang.String imageName)
Set the image from a file name. The specified file name must reside in "images" subfolder.

Parameters:
imageName - file nome used to retrieve the image

setToolTipText

public final void setToolTipText(java.lang.String toolTipText)
Set a tooltip text. This text will be translated according to the internationalization settings.

Parameters:
toolTipText - tool tip text entry in the dictionary

getToolTipText

public final java.lang.String getToolTipText()
Returns:
tool tip text entry in the dictionary

getImageName

public final java.lang.String getImageName()
Set the image from a file name. The specified file name must reside in "images" subfolder.


setScrollBarsPolicy

public final void setScrollBarsPolicy(int policy)
Determines when the scrollbars appears in the scrollpane. Legal values are:


getScrollBarsPolicy

public final int getScrollBarsPolicy()
Returns:
scrollbars policy; possible values: SCROLLBAR_AS_NEEDED, SCROLLBAR_NEVER, SCROLLBAR_ALWAYS

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)