当前位置: 首页>>代码示例>>Java>>正文


Java Font类代码示例

本文整理汇总了Java中java.awt.Font的典型用法代码示例。如果您正苦于以下问题:Java Font类的具体用法?Java Font怎么用?Java Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Font类属于java.awt包,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.awt.Font; //导入依赖的package包/类
@Override
public void init() {
this.setVisible(true);
this.setSize(500, 500);
this.setBackground(Color.green);
this.setLayout(new FlowLayout());

l1 = new Label("User Name");
l2 = new Label("Password");
tf1 = new TextField(20);
tf2 = new TextField(20);
tf2.setEchoChar('*');
b = new Button("Login");
b.addActionListener(this);

Font font = new Font("arial", Font.BOLD, 25);
l1.setFont(font);
l2.setFont(font);
tf1.setFont(font);
tf2.setFont(font);
b.setFont(font);

this.add(l1);
this.add(tf1);
this.add(l2);
this.add(tf2);
this.add(b);

}
 
开发者ID:pratikdimble,项目名称:Servlet_Applet_Communication,代码行数:30,代码来源:LoginApplet.java

示例2: setStyle

import java.awt.Font; //导入依赖的package包/类
protected void setStyle() {

        String fName = fullName.toLowerCase();

        for (int i=0; i < boldItalicNames.length; i++) {
            if (fName.indexOf(boldItalicNames[i]) != -1) {
                style = Font.BOLD|Font.ITALIC;
                return;
            }
        }

        for (int i=0; i < italicNames.length; i++) {
            if (fName.indexOf(italicNames[i]) != -1) {
                style = Font.ITALIC;
                return;
            }
        }

        for (int i=0; i < boldNames.length; i++) {
            if (fName.indexOf(boldNames[i]) != -1 ) {
                style = Font.BOLD;
                return;
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Font2D.java

示例3: SvnOptionsPanel

import java.awt.Font; //导入依赖的package包/类
/** Creates new form SvnOptionsPanel */
public SvnOptionsPanel() {
    initComponents();
    if(Utilities.isWindows()) {
        jLabel5.setText(org.openide.util.NbBundle.getMessage(SvnOptionsPanel.class, "SvnOptionsPanel.jLabel5.windows.text"));
        jLabel11.setText(org.openide.util.NbBundle.getMessage(SvnOptionsPanel.class, "SvnOptionsPanel.jLabel11.text"));
    } else {
        jLabel5.setText(org.openide.util.NbBundle.getMessage(SvnOptionsPanel.class, "SvnOptionsPanel.jLabel5.unix.text"));
        jLabel11.setText(org.openide.util.NbBundle.getMessage(SvnOptionsPanel.class, "SvnOptionsPanel.jLabel11.unix.text"));
    }
    Document doc = textPaneClient.getDocument();
    if (doc instanceof HTMLDocument) { // Issue 185505
        HTMLDocument htmlDoc = (HTMLDocument)doc;
        Font font = UIManager.getFont("Label.font"); // NOI18N
        String bodyRule = "body { font-family: " + font.getFamily() + "; " // NOI18N
            + "color: " + SvnUtils.getColorString(textPaneClient.getForeground()) + "; " //NOI18N
            + "font-size: " + font.getSize() + "pt; }"; // NOI18N
        htmlDoc.getStyleSheet().addRule(bodyRule);
    }
    textPaneClient.setOpaque(false);
    textPaneClient.setBackground(new Color(0,0,0,0)); // windows and nimbus workaround see issue 145826
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SvnOptionsPanel.java

示例4: getBelwe

import java.awt.Font; //导入依赖的package包/类
public static Font getBelwe(int size) {
    try {
        Font font = Font.createFont(Font.TRUETYPE_FONT, Fontes.class.getResourceAsStream("/com/limagiran/hearthstone/util/belwe.ttf"));
        font = font.deriveFont(Font.BOLD, size);
        return font;
    } catch (Exception ex) {
    }
    return new Font("Tahoma", Font.BOLD, size);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:10,代码来源:Fontes.java

示例5: TextLayout

import java.awt.Font; //导入依赖的package包/类
/**
 * Constructs a <code>TextLayout</code> from an iterator over styled text.
 * <p>
 * The iterator must specify a single paragraph of text because an
 * entire paragraph is required for the bidirectional
 * algorithm.
 * @param text the styled text to display
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       <code>TextLayout</code> and user space.
 */
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc) {

    if (text == null) {
        throw new IllegalArgumentException("Null iterator passed to TextLayout constructor.");
    }

    int start = text.getBeginIndex();
    int limit = text.getEndIndex();
    if (start == limit) {
        throw new IllegalArgumentException("Zero length iterator passed to TextLayout constructor.");
    }

    int len = limit - start;
    text.first();
    char[] chars = new char[len];
    int n = 0;
    for (char c = text.first();
         c != CharacterIterator.DONE;
         c = text.next())
    {
        chars[n++] = c;
    }

    text.first();
    if (text.getRunLimit() == limit) {

        Map<? extends Attribute, ?> attributes = text.getAttributes();
        Font font = singleFont(chars, 0, len, attributes);
        if (font != null) {
            fastInit(chars, font, attributes, frc);
            return;
        }
    }

    standardInit(text, chars, frc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:TextLayout.java

示例6: main

import java.awt.Font; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String os = System.getProperty("os.name");
    if (!os.startsWith("Mac")) {
         return;
    }
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();
    for (int i=0; i<fonts.length; i++) {
        if (fonts[i].getPSName().equals("Helvetica-LightOblique")) {
             helvFont = fonts[i];
             break;
        }
    }
    if (helvFont == null) {
        return;
    }
    final HelvLtOblTest test = new HelvLtOblTest();
    SwingUtilities.invokeLater(() -> {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add("Center", test);
        f.pack();
        f.setVisible(true);
    });
    test.compareImages();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:HelvLtOblTest.java

示例7: update

import java.awt.Font; //导入依赖的package包/类
void update(Attribute<String> labelAttr, Attribute<Font> fontAttr, Attribute<Color> colorAttr, int x, int y,
		int halign, int valign) {
	boolean wasReg = shouldRegister();
	this.labelAttr = labelAttr;
	this.fontAttr = fontAttr;
	this.colorAttr = colorAttr;
	this.fieldX = x;
	this.fieldY = y;
	this.halign = halign;
	this.valign = valign;
	boolean shouldReg = shouldRegister();
	AttributeSet attrs = comp.getAttributeSet();
	if (!wasReg && shouldReg)
		attrs.addAttributeListener(this);
	if (wasReg && !shouldReg)
		attrs.removeAttributeListener(this);

	updateField(attrs);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:InstanceTextField.java

示例8: CheckBoxFrame

import java.awt.Font; //导入依赖的package包/类
public CheckBoxFrame()
{
   super("JCheckBox Test");
   setLayout(new FlowLayout());

   // set up JTextField and set its font
   textField = new JTextField("Watch the font style change", 20);
   textField.setFont(new Font("Serif", Font.PLAIN, 14));
   add(textField); // add textField to JFrame

   boldJCheckBox = new JCheckBox("Bold"); 
   italicJCheckBox = new JCheckBox("Italic"); 
   add(boldJCheckBox); // add bold checkbox to JFrame
   add(italicJCheckBox); // add italic checkbox to JFrame

   // register listeners for JCheckBoxes
   CheckBoxHandler handler = new CheckBoxHandler();
   boldJCheckBox.addItemListener(handler);
   italicJCheckBox.addItemListener(handler);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:21,代码来源:CheckBoxFrame.java

示例9: getGraphicOrFont

import java.awt.Font; //导入依赖的package包/类
/**
 * Extract a GraphicAttribute or Font from the given attributes.
 * If attributes does not contain a GraphicAttribute, Font, or
 * Font family entry this method returns null.
 */
private static Object getGraphicOrFont(
        Map<? extends Attribute, ?> attributes) {

    Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT);
    if (value != null) {
        return value;
    }
    value = attributes.get(TextAttribute.FONT);
    if (value != null) {
        return value;
    }

    if (attributes.get(TextAttribute.FAMILY) != null) {
        return Font.getFont(attributes);
    }
    else {
        return null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:StyledParagraph.java

示例10: printHeaderFooter

import java.awt.Font; //导入依赖的package包/类
private void printHeaderFooter(Graphics g, PageFormat pageFormat, int page, String className)
{
    int origPage = page+1;

    // Add header
    g.setColor(Color.BLACK);
    int xOffset = (int)pageFormat.getImageableX();
    int topOffset = (int)pageFormat.getImageableY()+20;
    int bottom = (int)(pageFormat.getImageableY()+pageFormat.getImageableHeight());
    // header line
    g.drawLine(xOffset, topOffset-8, xOffset+(int)pageFormat.getImageableWidth(), topOffset-8);
    // footer line
    g.drawLine(xOffset,                                    bottom-11,
              xOffset+(int)pageFormat.getImageableWidth(), bottom-11);
    g.setFont(new Font(Font.SANS_SERIF,Font.ITALIC,10));

    Graphics2D gg = (Graphics2D) g;
    String pageString = "Page "+origPage;
    int tw = (int) gg.getFont().getStringBounds(pageString,gg.getFontRenderContext()).getWidth();
    
    // header text
    if(className!=null)
        g.drawString(className, xOffset, topOffset-10);
    // footer text
    g.drawString(pageString, xOffset+(int)pageFormat.getImageableWidth()-tw,bottom-2);
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:27,代码来源:BloxsEditor.java

示例11: setFontSize

import java.awt.Font; //导入依赖的package包/类
/**
 * Displays a color chooser and Sets the selected color.
 */
public static void setFontSize(String inFontSize) {

    // [email protected] 20050215 - Changed for Compatbilty fix for JDK 1.3
    // Convert Strng to float for deriveFont() call
    Float stageFloat = new Float(inFontSize);
    float fontSize   = stageFloat.floatValue();
    Font  fonttTree  = fOwner.tTree.getFont().deriveFont(fontSize);

    fOwner.tTree.setFont(fonttTree);

    Font fontTxtCommand =
        fOwner.txtCommand.getFont().deriveFont(fontSize);

    fOwner.txtCommand.setFont(fontTxtCommand);

    Font fontTxtResult = fOwner.txtResult.getFont().deriveFont(fontSize);

    fOwner.txtResult.setFont(fontTxtResult);
}
 
开发者ID:s-store,项目名称:s-store,代码行数:23,代码来源:FontDialogSwing.java

示例12: initBufferingAndFonts

import java.awt.Font; //导入依赖的package包/类
/**
 * Method description
 * 
 * @see
 */
final public void initBufferingAndFonts() {

	// Hardware double-buffering :
	RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
	this.setIgnoreRepaint(true);

	// Waiting for the frame to be displayed :
	while (!this.isVisible()) {
		Thread.yield();
	}

	// Images :
	final Graphics2D objLjuggleMasterProJFrameGraphics2D = (Graphics2D) this.getGraphics();

	this.initBounds();

	// Font metrics :
	this.objGnormalFont = objLjuggleMasterProJFrameGraphics2D.getFont();
	this.objGboldFont = this.objGnormalFont.deriveFont(Font.BOLD);
	Constants.objS_GRAPHICS_FONT_METRICS = objLjuggleMasterProJFrameGraphics2D.getFontMetrics();
	objLjuggleMasterProJFrameGraphics2D.dispose();
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:28,代码来源:AnimationJFrame.java

示例13: getMedicalWhiteColorScheme

import java.awt.Font; //导入依赖的package包/类
public static Theme getMedicalWhiteColorScheme() {
	Theme out = new Theme("Medical White");
	out.colors[COL_BACKGROUND] = new Color(0x888888);
	out.colors[COL_WINDOW_BACKGROUND] = new Color(0xbbbbbb);
	out.colors[COL_ACCENT] = new Color(0xbbbbbb);
	out.colors[COL_TEXT_PRIMARY] = new Color(0xffffff);
	out.colors[COL_TEXT_SECONDARY] = new Color(0xeeeeee);
	out.colors[COL_TEXT_TERTIARY] = new Color(0xdddddd);
	out.colors[COL_TEXT_STATUS] = new Color(0xdd9999);
	out.colors[COL_BUTTON] = new Color(0x555555);
	out.colors[COL_BUTTON_HOVER] = new Color(0xffffff);
	out.colors[COL_BUTTON_PRESS] = new Color(0xcccccc);
	out.colors[COL_INFO_WINDOW_BG] = new Color(0x666666);

	out.fonts[FONT_TITLE] = new Font("Mars Needs Cunnilingus", Font.BOLD, 45);
	return out;
}
 
开发者ID:Keabot-Studios,项目名称:Caritemere,代码行数:18,代码来源:Theme.java

示例14: getJButtonOntologyClassVisualsation

import java.awt.Font; //导入依赖的package包/类
/**
 * Returns the JButton for a OntologyClassVisualsation like for TimeSeries or XyChart's.
 *
 * @param dynType the current DynType
 * @param startArgIndex the start argument index
 * @return the JButton for special class
 */
private JButton getJButtonOntologyClassVisualsation(DynType dynType) {
	
	final DynType dynTypeCurrent = dynType;
	 
	JButton jButtonSpecialClass = new JButton();
	jButtonSpecialClass.setFont(new Font("Arial", Font.BOLD, 11));
	jButtonSpecialClass.setText("Edit");
	jButtonSpecialClass.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			dynTable.setOntologyClassVisualsationVisible(dynTypeCurrent);
		}
	});
	return jButtonSpecialClass;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:DynTableCellRenderEditor.java

示例15: getInstalledNames

import java.awt.Font; //导入依赖的package包/类
private static HashSet<String> getInstalledNames() {
    if (installedNames == null) {
       Locale l = getSystemStartupLocale();
       SunFontManager fontManager = SunFontManager.getInstance();
       String[] installedFamilies =
           fontManager.getInstalledFontFamilyNames(l);
       Font[] installedFonts = fontManager.getAllInstalledFonts();
       HashSet<String> names = new HashSet<String>();
       for (int i=0; i<installedFamilies.length; i++) {
           names.add(installedFamilies[i].toLowerCase(l));
       }
       for (int i=0; i<installedFonts.length; i++) {
           names.add(installedFonts[i].getFontName(l).toLowerCase(l));
       }
       installedNames = names;
    }
    return installedNames;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:SunFontManager.java


注:本文中的java.awt.Font类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。