本文整理汇总了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);
}
示例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;
}
}
}
示例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
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}