gpt4 book ai didi

java - 在 MacOS 上取消装饰 JInternalFrame

转载 作者:行者123 更新时间:2023-12-01 06:00:00 25 4
gpt4 key购买 nike

我正在尝试取消装饰JInternalFrame,即使用以下代码删除默认标题栏;

BasicInternalFrameUI ui = (BasicInternalFrameUI)internalFrame.getUI();
ui.getNorthPane().setPrefrredSize(new Dimension(0,0));

我在 Windows 上工作,但第二行在 MacOS 上抛出 NullPointerException

有什么想法以及如何解决它吗?

最佳答案

在 Mac 上,JInternalFrame 没有北 Pane 。仅在非 Mac OS 平台上执行代码;

// 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));
}

关于跨平台就这么多了:-(

关于java - 在 MacOS 上取消装饰 JInternalFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1082596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com