Class PaintSample

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class PaintSample
extends JComponent
A panel that displays a paint sample.
See Also:
Serialized Form
  • Constructor Details

    • PaintSample

      public PaintSample​(Paint paint)
      Standard constructor - builds a paint sample.
      Parameters:
      paint - the paint to display.
  • Method Details

    • getPaint

      public Paint getPaint()
      Returns the current Paint object being displayed in the panel.
      Returns:
      the paint.
    • setPaint

      public void setPaint​(Paint paint)
      Sets the Paint object being displayed in the panel.
      Parameters:
      paint - the paint.
    • getPreferredSize

      Returns the preferred size of the component.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      the preferred size.
    • paintComponent

      public void paintComponent​(Graphics g)
      Fills the component with the current Paint.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the graphics device.