本文整理汇总了Java中javax.swing.border.TitledBorder.getTitleFont方法的典型用法代码示例。如果您正苦于以下问题:Java TitledBorder.getTitleFont方法的具体用法?Java TitledBorder.getTitleFont怎么用?Java TitledBorder.getTitleFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.border.TitledBorder
的用法示例。
在下文中一共展示了TitledBorder.getTitleFont方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTitledBorderFont
import javax.swing.border.TitledBorder; //导入方法依赖的package包/类
public static Font getTitledBorderFont(TitledBorder tb) {
Font font = tb.getTitleFont();
if (font == null) font = UIManager.getFont("TitledBorder.font"); // NOI18N
if (font == null) font = new JLabel().getFont();
if (font == null) font = UIManager.getFont("Label.font"); // NOI18N
return font;
}
示例2: checkTitleFont
import javax.swing.border.TitledBorder; //导入方法依赖的package包/类
/**
* Check behaviour of method TitledBorder.getTitleFont()
*/
private static void checkTitleFont() {
TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
Font defaultFont = UIManager.getLookAndFeelDefaults().getFont("TitledBorder.font");
Font titledBorderFont = titledBorder.getTitleFont();
// check default configuration
if (defaultFont == null) {
if (titledBorderFont == null) {
return;
}
else {
throw new RuntimeException("TitledBorder default font should be null");
}
}
if (!defaultFont.equals(titledBorderFont)) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
// title font is explicitly specified
Font font = new Font("Dialog", Font.PLAIN, 10);
titledBorder.setTitleFont(font);
if (!font.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("TitledBorder font should be " + font.toString());
}
// title Font is unspecified
titledBorder.setTitleFont(null);
if (!defaultFont.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
}