本文整理了Java中javax.swing.JFrame.getFont()
方法的一些代码示例,展示了JFrame.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.getFont()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:getFont
暂无
代码示例来源:origin: stackoverflow.com
JFrame t = new JFrame();
t.setSize(600,300);
t.setFont(new Font("System", Font.PLAIN, 14));
Font f = t.getFont();
FontMetrics fm = t.getFontMetrics(f);
int x = fm.stringWidth("Hello Center");
int y = fm.stringWidth(" ");
int z = t.getWidth()/2 - (x/2);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" ";
pad = String.format("%"+w+"s", pad);
t.setTitle(pad+"Hello Center");
代码示例来源:origin: klamonte/jexer
/**
* Gets the font of this component.
*
* @return this component's font; if a font has not been set for this
* component, the font of its parent is returned
*/
public Font getFont() {
if (frame != null) {
return frame.getFont();
} else {
return component.getFont();
}
}
代码示例来源:origin: stackoverflow.com
JFrame t = new JFrame();
t.setSize(600,300);
t.setFont(new Font("System", Font.PLAIN, 14));
Font f = t.getFont();
FontMetrics fm = t.getFontMetrics(f);
int x = fm.stringWidth("Hello Center");
int y = fm.stringWidth(" ");
int z = t.getWidth()/2 - (x/2);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" ";
pad = String.format("%"+w+"s", pad);
t.setTitle(pad+"Hello Center");
代码示例来源:origin: geogebra/geogebra
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setVisible(true);
Graphics2D g = (Graphics2D) frame.getGraphics();
for (int i = 0; i < 3000; i++) {
char c = (char) i;
TextLayoutD ld = new TextLayoutD(c + "", frame.getFont(),
g.getFontRenderContext());
System.out.println(i + " (" + c + ") : "
+ ld.getBounds().getY() / ld.getBounds().getHeight());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!