Package java.awt

Examples of java.awt.FontMetrics.stringWidth()


    if (str == null) {
      return 0;
    }

    FontMetrics metrics = HELPER_LABEL.getFontMetrics(font);
    return metrics.stringWidth(str);
  }

  /**
   * Gets the width of the specified char array.
   *
 
View Full Code Here


    if (fatalError) {
      String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;

      for(int i=0; i<errorMessage.length; i++) {
        if(errorMessage[i] != null) {
          int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2;
          int messageY = (offscreen.getHeight(null) - (fm.getHeight() * errorMessage.length)) / 2;

          og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
        }
      }
 
View Full Code Here

      if (logo != null) {
        og.drawImage(logoBuffer, x-logo.getWidth(null)/2, y-logo.getHeight(null)/2, this);
      }

      // draw message
      int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
      int messageY = y + 20;

      if (logo != null) messageY += logo.getHeight(null)/2;
      else if (progressbar != null) messageY += progressbar.getHeight(null)/2;
View Full Code Here

      og.drawString(message, messageX, messageY);

      // draw subtaskmessage, if any
      if(subtaskMessage.length() > 0) {
        messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2;
        og.drawString(subtaskMessage, messageX, messageY+20);
      }

      // draw loading bar, clipping it depending on percentage done
      if (progressbar != null) {
View Full Code Here

    int yoffset = metrics.getHeight();

    StringTokenizer tokenizer = new StringTokenizer(text, " ", true);
    while (tokenizer.hasMoreTokens()) {
      String token = tokenizer.nextToken();
      int tokenWidth = metrics.stringWidth(token);
      if (xoffset + tokenWidth > width) {
        yoffset += metrics.getHeight();
        xoffset = 0;
      }
      g.drawString(token, xoffset + insets.left, yoffset + insets.bottom);
View Full Code Here

            int y = point1.y + symbol_.getIconHeight()
                    + echelon_.getIconHeight();
            Font font = new Font("Helvetica", java.awt.Font.PLAIN, 10);
            g.setFont(font);
            FontMetrics fm = g.getFontMetrics();
            int w = fm.stringWidth(eunit.bottom1);
            int h = fm.getHeight();
            total_height += h;
            if (w > total_width)
                total_width = w;
            x -= w / 2;
View Full Code Here

        Graphics g = bi.getGraphics();
        g.setFont(f);
        g.setColor(Color.black);
        FontMetrics fm = g.getFontMetrics();

        int stringWidth = fm.stringWidth(s);
        int stringHeight = f.getSize() - 2;
        g.drawString(s, (width - stringWidth) / 2, height - (height - stringHeight) / 2);
        return new ImageIcon(bi);
    }
View Full Code Here

    for(int i=0;i<modes.length;i++)
      g.drawString(modes[i],100+(50*i),ty-14);
   
    FontMetrics fm = g.getFontMetrics();
    for(int i=0;i<fonts.length;i++)
      g.drawString(fonts[i],98-fm.stringWidth(fonts[i]),ty+(12*i));
   
    Font cf = g.getFont();
   
    for(int i=0;i<fonts.length;i++) {
      for(int j=0;j<modes.length;j++) {
View Full Code Here

        // something correct
        width = (float) bounds.getWidth();
      }
      else
      {
        width = fm.stringWidth(text);
      }


      final LineMetrics metrics = f.getLineMetrics(text, frc);
      final float descent = metrics.getDescent();
View Full Code Here

            {
                g.setColor( m_color );
            }           
           
            FontMetrics fm = g.getFontMetrics();
            int width = fm.stringWidth(m_text) + 20;
            int height = fm.getHeight();
           
            g.drawString(m_text, getWidth() - width, getHeight() - height);
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.