public class MattePainter<T> extends AbstractAreaPainter<T>
MattePainter p = new MattePainter(Color.GREEN);
panel.setBackgroundPainter(p);
Since it accepts a Paint, it is also possible to paint a texture or use other more exotic Paint implementations. To paint a BufferedImage texture as the background:
TexturePaint paint = new TexturePaint(bufferedImage,
new Rectangle2D.Double(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()));
MattePainter p = new MattePainter(paint);
panel.setBackgroundPainter(p);
If no paint is specified, then nothing is painted
AbstractAreaPainter.Style
AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignment
AbstractPainter.Interpolation
Constructor and Description |
---|
MattePainter()
Creates a new MattePainter with "null" as the paint used
|
MattePainter(java.awt.Paint paint)
Create a new MattePainter for the given Paint.
|
MattePainter(java.awt.Paint paint,
boolean paintStretched)
Create a new MattePainter for the given Paint.
|
Modifier and Type | Method and Description |
---|---|
void |
doPaint(java.awt.Graphics2D g,
T component,
int width,
int height)
Subclasses must implement this method and perform custom painting operations
here.
|
java.awt.Shape |
provideShape(java.awt.Graphics2D g,
T comp,
int width,
int height)
Returns the outline shape of this painter.
|
getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyle
calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignment
clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
public MattePainter()
public MattePainter(java.awt.Paint paint)
paint
- Paint to fill withpublic MattePainter(java.awt.Paint paint, boolean paintStretched)
paint
- Paint to fill withpaintStretched
- indicates if the paint should be stretchedpublic void doPaint(java.awt.Graphics2D g, T component, int width, int height)
AbstractPainter
doPaint
in class AbstractPainter<T>
g
- The Graphics2D object in which to paintpublic java.awt.Shape provideShape(java.awt.Graphics2D g, T comp, int width, int height)
AbstractAreaPainter
provideShape
in class AbstractAreaPainter<T>
g
- graphicscomp
- The Object this painter will be painted on.width
- the width to paintheight
- the height to paint