Package java.awt

Examples of java.awt.FontMetrics.stringWidth()


        renderer.getTableCellRendererComponent(
          table, table.getValueAt(i, index), false, false, i, index);

      if (c instanceof JLabel) {
        longestWidth =
          Math.max(longestWidth, metrics.stringWidth(((JLabel) c).getText()));
      }
    }

    return longestWidth + 5;
  }
View Full Code Here


        FontMetrics metrics;
        int width;
        int height;

        metrics = getFontMetrics(getFont());
        width = metrics.stringWidth("http://localhost");
        height =
            metrics.getLeading() + metrics.getHeight() + metrics.getDescent();

        return (new Dimension(width, height));
    }
View Full Code Here

        FontMetrics metrics;
        int width;
        int height;

        metrics = getFontMetrics(getFont());
        width = metrics.stringWidth("Hello World");
        height =
            metrics.getLeading() + metrics.getHeight() + metrics.getDescent();

        return (new Dimension(width, height));
    }
View Full Code Here

    // TODO list table tree
    if (text == null) { text = getString(mouseinside, "tooltip", null); }
      else { tooltipowner = insidepart; }
    if (text != null) {
      FontMetrics fm = getFontMetrics(font);
      int width = fm.stringWidth(text) + 4;
      int height = fm.getAscent() + fm.getDescent() + 4;
      if (tooltipowner == null) { tooltipowner = mouseinside; }
      Rectangle bounds = getRectangle(content, "bounds");
      int tx = Math.max(0, Math.min(mousex + 10, bounds.width - width));
      int ty = Math.max(0, Math.min(mousey + 10, bounds.height - height));
View Full Code Here

    int offset = getInteger(component, ":offset", 0);
    int off = offset;
    Font currentfont = (Font) get(component, "font");
    FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
    int caret = hidden ? (fm.charWidth('*') * end) :
      fm.stringWidth(text.substring(0, end));
    if (off > caret) {
      off = caret;
    }
    else if (off < caret - width + 4) {
      off = caret - width + 4;
View Full Code Here

    }
    else if (off < caret - width + 4) {
      off = caret - width + 4;
    }
    off = Math.max(0, Math.min(off, (hidden ? (fm.charWidth('*') *
      text.length()) : fm.stringWidth(text)) - width + 4));
    if (off != offset) {
      setInteger(component, ":offset", off, 0);
    }
  }

View Full Code Here

    String text = getString(component, "text", null);
    int tw = 0; int th = 0;
    if (text != null) {
      Font customfont = (Font) get(component, "font");
      FontMetrics fm = getFontMetrics((customfont != null) ? customfont : font);
      tw = fm.stringWidth(text);
      th = fm.getAscent() + fm.getDescent();
    }
    Image icon = getIcon(component, "icon", null);
    int iw = 0; int ih = 0;
    if (icon != null) {
View Full Code Here

    int caret = 0;
    if (focus) {
      int start = getInteger(component, "start", 0);
      int end = getInteger(component, "end", 0);
      caret = hidden ? (fm.charWidth('*') * end) :
        fm.stringWidth(text.substring(0, end));
      if (start != end) {
        int is = hidden ? (fm.charWidth('*') * start) :
          fm.stringWidth(text.substring(0, start));
        g.setColor(c_select);
        g.fillRect(2 + left - offset + Math.min(is, caret), 1,
View Full Code Here

      int end = getInteger(component, "end", 0);
      caret = hidden ? (fm.charWidth('*') * end) :
        fm.stringWidth(text.substring(0, end));
      if (start != end) {
        int is = hidden ? (fm.charWidth('*') * start) :
          fm.stringWidth(text.substring(0, start));
        g.setColor(c_select);
        g.fillRect(2 + left - offset + Math.min(is, caret), 1,
          Math.abs(caret - is) + evm, height - 2 + evm);
      }
    }
View Full Code Here

    FontMetrics fm = null;
    int tw = 0, th = 0;
    int ta = 0;
    if (text != null) {
      fm = g.getFontMetrics();
      tw = fm.stringWidth(text);
      ta = fm.getAscent();
      th = fm.getDescent() + ta;
    }
    int iw = 0, ih = 0;
    if (icon != null) {
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.