Examples of charWidth()


Examples of java.awt.FontMetrics.charWidth()

    FontMetrics fm = cb.getFontMetrics(cb.getFont());
   
    // for an editable JComboBox the display size is calculated from the
    // preferred size of the JTextField it seems, or the prototype display
    // value in some cases...
    int width = fm.charWidth('m') * columns;
    int height = fm.getHeight() + 2// the 2 seems to be a fixed margin
   
    // not sure why the width here needs + 1..
    harness.check(ui.getDisplaySize(), new Dimension(width + 1, 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.getDefaultSize(), new Dimension(width, height));
    cb.setFont(new Font("Dialog", Font.PLAIN, 32));
    fm = cb.getFontMetrics(cb.getFont());
    width = fm.charWidth(' ') + additionalWidth;
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    int width = fm.charWidth(' ') + additionalWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getDefaultSize(), new Dimension(width, height));
    cb.setFont(new Font("Dialog", Font.PLAIN, 32));
    fm = cb.getFontMetrics(cb.getFont());
    width = fm.charWidth(' ') + additionalWidth;
    height = fm.getHeight() + additionalHeight;
    harness.check(ui.getDefaultSize(), 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.getMinimumSize(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()

    harness.check(ui.getMinimumSize(cb), 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.getMinimumSize(cb), new Dimension(width + height, height));
   
    cb.setPrototypeDisplayValue("XX");   
    width = fm.stringWidth("XX") + additionalWidth;
    harness.check(ui.getMinimumSize(cb), new Dimension(width + height, height));
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

                int lenght = SCREEN_WIDTH;
                if (offset <= cursorOffset && cursorOffset < offset + SCREEN_WIDTH) {
                    FontMetrics fm = getFontMetrics(getFont());
                    int x = margin + fm.charsWidth(buffer, offset, cursorOffset - offset);
                    int y = h + i * h;
                    int width = fm.charWidth(buffer[cursorOffset]);
                    g.drawLine(x, y, x + width, y);
                }
                g.drawChars(buffer, offset, lenght, margin, h + i * h);

            }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

           
                // draw the cursor
                if (cursorVisible && (cursorOffset >= offset) && (cursorOffset < (offset + length))) {
                    final int x1 = fm.charsWidth(buffer, offset, cursorOffset - offset);
                    final char charUnderCursor = buffer[cursorOffset];
                    final int width = fm.charWidth(charUnderCursor);
                   
                    graphics.fillRect(x1, y - fontHeight + 1, width, fontHeight);
                    if (charUnderCursor >= ' ') {
                        graphics.setColor(Color.BLACK);
                        graphics.drawChars(textBuffer, cursorOffset, 1, x1, y);
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

Examples of java.awt.FontMetrics.charWidth()

    FontMetrics fm = cb.getFontMetrics(cb.getFont());
   
    // for an editable JComboBox the display size is calculated from the
    // preferred size of the JTextField it seems, or the prototype display
    // value in some cases...
    int width = fm.charWidth('m') * columns;
    int height = fm.getHeight() + 2// the 2 seems to be a fixed margin
   
    // not sure why the width here needs + 1..
    harness.check(ui.getDisplaySize(), new Dimension(width + 1, height));
   
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

                = selectionList.getFontMetrics(selectionList.getFont());
            Dimension size;
            if (optionModel.getSize() == 0) {
                size = selectionList.getPreferredSize();
                Insets insets = selectionList.getInsets();
                size.width = fontMetrics.charWidth(MEAN_CHAR)
                             + insets.left + insets.right;
                selectionList.setPreferredSize(size);
            }

            JScrollPane pane = new JScrollPane(selectionList,
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.