本文介绍了在MacOS上取消装饰JInternalFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试取消装饰 JInternalFrame
,即使用以下代码删除默认标题栏;
I am trying to undecorate a JInternalFrame
, i.e. remove the default titlebar using the following code;
BasicInternalFrameUI ui = (BasicInternalFrameUI)internalFrame.getUI();
ui.getNorthPane().setPrefrredSize(new Dimension(0,0));
我在Windows上工作,但第二行在MacOS上抛出NullPointerException
I works on windows but the second line throws a NullPointerException on MacOS
任何想法为何以及如何解决?
Any ideas why and how to get round it?
推荐答案
在Mac上,JInternalFrame没有北面板.仅在无Mac OS平台上执行代码;
On Mac, the JInternalFrame doesn't have a north pane. Only execute the code on none Mac OS platforms;
// only remove the northpanel for none Mac OS
if(!(System.getProperty("os.name").startsWith("Mac OS"))){
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
ui.getNorthPane().setPrefrredSize(new Dimension(0,0));
}
关于跨平台的很多内容:-(
So much about cross platform :-(
这篇关于在MacOS上取消装饰JInternalFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!