Package java.awt

Examples of java.awt.Font.canDisplayUpTo()


    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      Font font = new Font((String) value, Font.PLAIN, 20);
      if (font.canDisplayUpTo(label.getText()) == -1) { // -1 means, can display all of the string
        label.setFont(font);
      }
      return label;
    }
  }
View Full Code Here


      int index, boolean isSelected, boolean cellHasFocus) {
    JLabel label = (JLabel) super.getListCellRendererComponent(list, value,
        index, isSelected, cellHasFocus);
    String str = value.toString();
    Font font = new Font(str, Font.PLAIN, 14);
    if(font.canDisplayUpTo(str) == -1)
      label.setFont(font);
    else
      label.setFont(new Font(label.getFont().getFontName(), Font.PLAIN, 14));
    return label;
  }
View Full Code Here

        Theme theme = Theme.getTheme();
        Font font = theme.getFont();

        // Search for a font that can support the sample string
        String sampleResource = resources.getString("firstName");
        if (font.canDisplayUpTo(sampleResource) != -1) {
            Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();

            for (int i = 0; i < fonts.length; i++) {
                if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
                    theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
View Full Code Here

    {
        Font _awtFont = getawtFont();

        // mdavis - fix fontmanager.so/dll on sun.font.FileFont.getGlyphImage
        // for font with bad cmaps?
        if (_awtFont.canDisplayUpTo(string) != -1) {
            log.warn("Changing font on <" + string + "> from <"
                    + _awtFont.getName() + "> to the default font");
            _awtFont = Font.decode(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.