示例#1
0
 protected void drawText(Graphics2D g2) {
   // Find the bounds of the entire string.
   FontRenderContext frc = g2.getFontRenderContext();
   mLayout = new TextLayout(mMessage, mFont, frc);
   // Find the dimensions of this component.
   int width = getSize().width;
   int height = getSize().height;
   // Place the first full string, horizontally centered,
   //   at the bottom of the component.
   Rectangle2D bounds = mLayout.getBounds();
   double x = (width - bounds.getWidth()) / 2;
   double y = height - bounds.getHeight();
   drawString(g2, x, y, 0);
   // Now draw a second version, anchored to the right side
   //   of the component and rotated by -PI / 2.
   drawString(g2, width - bounds.getHeight(), y, -Math.PI / 2);
 }