Class DrawStringPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DrawStringPanel extends JPanel
A panel used by the DrawStringDemo class.
See Also:
  • Field Details

    • PREFERRED_SIZE

      private static final Dimension PREFERRED_SIZE
      The preferred size for the panel.
    • rotate

      private boolean rotate
      Is the text rotated.
    • text

      private String text
      The text to display.
    • anchor

      private TextAnchor anchor
      The text anchor.
    • rotationAnchor

      private TextAnchor rotationAnchor
      The rotation anchor.
    • font

      private Font font
      The font.
    • angle

      private double angle
      The rotation angle.
  • Constructor Details

    • DrawStringPanel

      public DrawStringPanel(String text, boolean rotate)
      Creates a new panel.
      Parameters:
      text - the text.
      rotate - a flag that controls whether or not the text is rotated.
  • Method Details

    • getPreferredSize

      public Dimension getPreferredSize()
      Returns the preferred size for the panel.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      The preferred size.
    • setAnchor

      public void setAnchor(TextAnchor anchor)
      Sets the text anchor.
      Parameters:
      anchor - the text anchor.
    • setRotationAnchor

      public void setRotationAnchor(TextAnchor anchor)
      Sets the rotation anchor.
      Parameters:
      anchor - the rotation anchor.
    • setAngle

      public void setAngle(double angle)
      Sets the rotation angle.
      Parameters:
      angle - the rotation angle.
    • getFont

      public Font getFont()
      Returns the font.
      Specified by:
      getFont in interface MenuContainer
      Overrides:
      getFont in class Component
      Returns:
      The font.
    • setFont

      public void setFont(Font font)
      Sets the font.
      Overrides:
      setFont in class JComponent
      Parameters:
      font - the font.
    • paintComponent

      public void paintComponent(Graphics g)
      Paints the panel.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the graphics device.