我正在使用Nimbus外观,并且我已经设置了一个这样的defaultFont。
NimbusLookAndFeel nimbus = new NimbusLookAndFeel();
nimbus.getDefaults().put("defaultFont", myFont);它工作得很完美。但是我有一个带JButton的JFrame。我只想对JFrame和JFrame的所有组件使用不同的"defaultFont“。
但是我该怎么做呢?
编辑:在我的JFrame中,我尝试覆盖defaultFont的值,如下所示。
UIDefaults jDefaults = new UIDefaults();
jDefaults.put("defaultFont", newFont);
this.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
this.putClientProperty("Nimbus.Overrides", jDefaults);
//SwingUtilities.updateComponentTreeUI(this); It doesn't work
System.Out.println(getFont()); // writting myFont instead of newFont发布于 2015-08-05 21:59:40
设置好字体后,你有没有尝试过:
for(Window window : JFrame.getWindows()) {
SwingUtilities.updateComponentTreeUI(window);
}https://stackoverflow.com/questions/31834111
复制相似问题