Class TextPainter

java.lang.Object
com.codename1.ui.scene.TextPainter
All Implemented Interfaces:
NodePainter

public class TextPainter extends Object implements NodePainter
A painter for painting text into a Node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextPainter(String text, int valign)
    Creates a new TextPainter with the given text and vertical alignment.
  • Method Summary

    Modifier and Type
    Method
    Description
    The text of this painter.
    int
    Gets the vertical alignment of this text.
    void
    paint(Graphics g, Rectangle bounds, Node node)
    Paints the text onto the provided graphics context.
    void
    Sets the text of this painter
    void
    setvAlign(int vAlign)
    Sets the vertical alignment.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • TextPainter

      public TextPainter(String text, int valign)

      Creates a new TextPainter with the given text and vertical alignment.

      Parameters
      • text: The text to paint.

      • valign: The vertical alignment of the text. One of Component#CENTER, Component#TOP, Component#BOTTOM.

  • Method Details

    • paint

      public void paint(Graphics g, Rectangle bounds, Node node)

      Paints the text onto the provided graphics context.

      Parameters
      • g: The graphics to paint onto.

      • bounds: The bounding rect.

      • node: The node whose content we are painting.

      Specified by:
      paint in interface NodePainter
    • getText

      public String getText()

      The text of this painter.

      Returns

      the text

    • setText

      public void setText(String text)

      Sets the text of this painter

      Parameters
      • text: the text to set
    • getvAlign

      public int getvAlign()

      Gets the vertical alignment of this text. One of Component#CENTER, Component#TOP, Component#BOTTOM.

      Returns

      the vAlign

    • setvAlign

      public void setvAlign(int vAlign)

      Sets the vertical alignment. One of Component#CENTER, Component#TOP, Component#BOTTOM.

      Parameters
      • vAlign: the vAlign to set