Examples of charWidth()


Examples of java.awt.FontMetrics.charWidth()

      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,
          Math.abs(caret - is) + evm, height - 2 + evm);
      }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    g.setColor(enabled ? c_text : c_disable);
    int fx = 2 + left - offset;
    int fy = (height + fm.getAscent() - fm.getDescent()) / 2;
    if (hidden) {
      int fh = fm.charWidth('*');
      for (int i = text.length(); i > 0; i--) {
        g.drawString("*", fx, fy);
        fx += fh;
      }
    } else {
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

      g.drawString(text, cx, ty);
      if (mnemonic) {
        int imnemonic = getInteger(component, "mnemonic", -1);
        if ((imnemonic != -1) && (imnemonic < text.length())) {
          int mx = cx + fm.stringWidth(text.substring(0, imnemonic));
          g.drawLine(mx, ty + 1, mx + fm.charWidth(text.charAt(imnemonic)), ty + 1);
        }
      }
      if (underline) { // for link button
        g.drawLine(cx, ty + 1, cx + tw, ty + 1);
      }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

        }
      }
    }
    for (int i = linestart; i < chars.length; i++) {
      if ((chars[i] == '\n') || (chars[i] == '\t')) { return i; }
      int charwidth = fm.charWidth(hidden ? '*' : chars[i]);
      if (x <= (charwidth / 2)) { return i; }
      x -= charwidth;
    }
    return chars.length;
  }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

            for (int i = 0; i < captchaCode.length(); i++) {

                // this is a separate canvas used for the character so that
                // we can rotate it independently
                int charWidth = fontMetrics.charWidth(captchaCode.charAt(i));
                int charDim = Math.max(maxAdvance, fontHeight);
                int halfCharDim = (charDim / 2);

                BufferedImage charImage =
                    new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    FontMetrics fm = cb.getFontMetrics(cb.getFont());

    // the following width calculation is a guess.  We know the value
    // depends on the font size, and that it is relatively small, so after
    // trying out a few candidates this one seems to give the right result
    int width = fm.charWidth(' ') + additionalWidth + iconWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
   
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
    width = fm.charWidth('X') + additionalWidth + iconWidth;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
   
    cb.setPrototypeDisplayValue("XX");   
    width = fm.stringWidth("XX") + additionalWidth + iconWidth;
    harness.check(ui.getMinimumSize(cb), new Dimension(width, height));
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    FontMetrics fm = cb.getFontMetrics(cb.getFont());
   
    // the following width calculation is a guess.  We know the value
    // depends on the font size, and that it is relatively small, so after
    // trying out a few candidates this one seems to give the right result
    int width = fm.charWidth(' ') + additionalWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getPreferredSize(cb),
            new Dimension(width + height, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

            new Dimension(width + height, height));
                   // the width is the display width plus the button width and
                   // the button width is equal to 'height'
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
    width = fm.charWidth('X') + additionalWidth;
    harness.check(ui.getPreferredSize(cb),
            new Dimension(width + height, height));
   
    cb.setModel(new DefaultComboBoxModel(new Object[] {null}));
    harness.check(ui.getPreferredSize(cb).height, height);
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    FontMetrics fm = cb.getFontMetrics(cb.getFont());
   
    // the following width calculation is a guess.  We know the value
    // depends on the font size, and that it is relatively small, so after
    // trying out a few candidates this one seems to give the right result
    int width = fm.charWidth(' ') + additionalWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getDisplaySize(), new Dimension(width, height));
   
    cb.addItem("ABC");
    width = fm.stringWidth("ABC") + additionalWidth;
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.