我必须将Jframe
和JOptionPane
元素的标题栏指定为柬埔寨语(unicode)文本数据。
默认字体(对话框)无法正确呈现文本,我想将默认字体覆盖为其他字体。
请帮忙,我该如何覆盖它?
我尝试了以下方法,但都没有奏效。(LaF:物质 7.2.1)
UIManager.put("OptionPane.font", new FontUIResource(Main.get_ui_font()));
UIManager.put("TitledBorder.font", Main.get_ui_font());
UIManager.put("Frame.font", Main.get_ui_font());
我在上面用Font
and进行了测试FontUIResource
,没有区别!
下面的代码抛出了一个内部物质 api 异常,它是 about nullpointerexception
,但是在完整的堆栈中,我看不到我的代码的任何堆栈跟踪,太奇怪了,可能是一个错误。
SubstanceLookAndFeel.setFontPolicy(new FontPolicy() {public FontSet getFontSet(String arg0, UIDefaults arg1) {
FontSet fs=new FontSet() {
public FontUIResource getWindowTitleFont() {return new FontUIResource(Main.get_ui_font());}
public FontUIResource getTitleFont() {return new FontUIResource(Main.get_ui_font());}
public FontUIResource getSmallFont() {return new FontUIResource(Main.get_ui_font().deriveFont(10.0F));}
public FontUIResource getMessageFont() {return new FontUIResource(Main.get_ui_font());}
public FontUIResource getMenuFont() {return new FontUIResource(Main.get_ui_font());}
public FontUIResource getControlFont() {return new FontUIResource(Main.get_ui_font());}
};
return fs;
}
});
上述代码的完整堆栈跟踪
Exception in thread "main" java.lang.NullPointerException
at org.pushingpixels.substance.api.SubstanceLookAndFeel.setSkin(SubstanceLookAn
dFeel.java:2150)
at org.pushingpixels.substance.api.SubstanceLookAndFeel.access$000(SubstanceLoo
kAndFeel.java:92)
at org.pushingpixels.substance.api.SubstanceLookAndFeel$3.run(SubstanceLookAndF
eel.java:2136)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.ja
va:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java
:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:11
6)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)