All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.wizards.awt.ImagePanel

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----com.sun.wizards.awt.InsetsPanel
                                   |
                                   +----com.sun.wizards.awt.ImagePanel

public class ImagePanel
extends InsetsPanel
The ImagePanel is a panel that displays an image. The image can be aligned horizontally and vertically. The default alignment for both directions is centered.

Graphic of ImagePanel displaying a centered image.

Here is the code for this applet:


 import java.applet.Applet;
 import java.awt.*;
 import com.sun.wizards.awt.*;
 public class Test extends Applet
 {
   public void init()
     {
       setLayout(new BorderLayout());
       ImagePanel imagePanel = new ImagePanel();
       Image image = getImage(getCodeBase(), "images/JAVA.85.GIF");
       imagePanel.setImage(image);
       add(imagePanel, "Center");
     }
 }
 


Variable Index

 o BOTTOM
Bottom image alignment.
 o CENTER
Center image alignment.
 o hAlign
The horizontal alignment of the image.
 o image
The current image that this panel will display.
 o LEFT
Left image alignment.
 o loaded
Keeps the status of the current image.
 o RIGHT
Right image alignment.
 o TOP
Top image alignment.
 o vAlign
The vertical alignment of the image.

Constructor Index

 o ImagePanel()
Creates a new ImagePanel using the default layout manager.
 o ImagePanel(Insets)
Creates a new ImagePanel with the specified Insets.
 o ImagePanel(int, int)
Creates a new ImagePanel with the specified image alignments.
 o ImagePanel(LayoutManager)
Creates a new ImagePanel with the specified layout manager.

Method Index

 o getMinimumSize()
Gets the minimum size of this component.
 o getPreferredSize()
Gets the preferred size of this component.
 o imageUpdate(Image, int, int, int, int, int)
This version of imageUpdate paints the specified image only after the entire image has been loaded.
 o paint(Graphics)
Paints any components that are children of this container, and then paints the current image, if one has been set.
 o setAlignment(int, int)
sets the image alignment of this ImagePanel
 o setImage(Image)
Set the image to be displayed by this ImagePanel.

Variables

 o LEFT
 public static final int LEFT
Left image alignment.

 o CENTER
 public static final int CENTER
Center image alignment.

 o RIGHT
 public static final int RIGHT
Right image alignment.

 o TOP
 public static final int TOP
Top image alignment.

 o BOTTOM
 public static final int BOTTOM
Bottom image alignment.

 o image
 protected Image image
The current image that this panel will display.

 o hAlign
 protected int hAlign
The horizontal alignment of the image.

 o vAlign
 protected int vAlign
The vertical alignment of the image.

 o loaded
 protected boolean loaded
Keeps the status of the current image. If true, the image has been completely loaded. Otherwise, the image has not been loaded.

Constructors

 o ImagePanel
 public ImagePanel()
Creates a new ImagePanel using the default layout manager. The default layout manager for all panels is the FlowLayout class.

 o ImagePanel
 public ImagePanel(LayoutManager layout)
Creates a new ImagePanel with the specified layout manager.

Parameters:
layout - The layout manager for this ImagePanel.
 o ImagePanel
 public ImagePanel(Insets insets)
Creates a new ImagePanel with the specified Insets.

Parameters:
insets - The insets for this ImagePanel.
 o ImagePanel
 public ImagePanel(int hAlign,
                   int vAlign)
Creates a new ImagePanel with the specified image alignments.

Parameters:
hAlign - The desired horizontal alignment.
vAlign - The desired vertical alignment.

Methods

 o setImage
 public void setImage(Image image)
Set the image to be displayed by this ImagePanel.

Parameters:
image - The new image to be displayed.
 o setAlignment
 public void setAlignment(int hAlign,
                          int vAlign)
sets the image alignment of this ImagePanel

Parameters:
hAlign - The desired horizontal alignment.
vAlign - The desired vertical alignment.
 o getPreferredSize
 public Dimension getPreferredSize()
Gets the preferred size of this component.

Returns:
A dimension object indicating this component's preferred size.
Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Gets the minimum size of this component.

Returns:
A dimension object indicating this component's minimum size.
Overrides:
getMinimumSize in class Container
 o paint
 public void paint(Graphics g)
Paints any components that are children of this container, and then paints the current image, if one has been set.

Parameters:
g - The specifiecd Graphics window.
Overrides:
paint in class Container
 o imageUpdate
 public synchronized boolean imageUpdate(Image image,
                                         int infoFlags,
                                         int x,
                                         int y,
                                         int width,
                                         int height)
This version of imageUpdate paints the specified image only after the entire image has been loaded. This gives the appearence of better performance at runtime.

Parameters:
image - The image being observed.
infoFlags - See imageUpdate for more information.
x - The x coordinate.
y - The y coordinate.
width - The width.
height - The height.
Returns:
true if the flags indicate that the images is completely loaded; false otherwise.
Overrides:
imageUpdate in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index