隐藏JInternalFrame的标题栏-JAVA
我在网上找到了一些代码,我编辑了一些。我想隐藏JInternalFrame的标题栏隐藏JInternalFrame的标题栏-JAVA,java,swing,user-interface,jframe,jinternalframe,Java,Swing,User Interface,Jframe,Jinternalframe,我在网上找到了一些代码,我编辑了一些。我想隐藏JInternalFrame的标题栏 JInternalFrame frame = new JInternalFrame(); // Get the title bar and set it to null setRootPaneCheckingEnabled(false); javax.swing.plaf.InternalFrameUI ifu= frame.getUI(); ((javax.swing.plaf.basic.
JInternalFrame frame = new JInternalFrame();
// Get the title bar and set it to null
setRootPaneCheckingEnabled(false);
javax.swing.plaf.InternalFrameUI ifu= frame.getUI();
((javax.swing.plaf.basic.BasicInternalFrameUI)ifu).setNorthPane(null);
frame.setLocation(i*50+10, i*50+10);
frame.setSize(200, 150);
//frame.setBackground(Color.white);
frame.setVisible(true);
desktop.add(frame);
问题是标题栏由于某种原因没有被隐藏。
谢谢。首先将内部框架转换为基本内部框架 这样做:-
BasicInternalFrameUI bi = (BasicInternalFrameUI)your_internalframe_object.getUI();
bi.setNorthPane(null);
在此之后,您的标题栏将不可见。我通过以下方式解决了此问题:我将子类化JInternalFrame,并将以下代码添加到其构造函数中。(我免费获得子类化,因为我使用netBeans的GUI生成器)
在你的情况下,我认为这对我来说非常有效:
putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
((BasicInternalFrameUI) this.getUI()).setNorthPane(null);
this.setBorder(null);
谢谢。其他人怎么说。不过,根据框架的不同,ui可能会得到更新,从而使其重新出现。因此,对我来说,它可以像这样初始化JInternalFrame:
JInternalFrame internalFrame = new JInternalFrame() {
@Override
public void setUI(InternalFrameUI ui) {
super.setUI(ui); // this gets called internally when updating the ui and makes the northPane reappear
BasicInternalFrameUI frameUI = (BasicInternalFrameUI) getUI(); // so...
if (frameUI != null) frameUI.setNorthPane(null); // lets get rid of it
}
};
很好,这是正确的答案,不像.setUI(null)!我还读到,在某些事件(如最小化窗口)后,您可能需要再次执行此操作。这是正确的答案。当与
frame.setBorder(null)结合使用时,它也很有用
将a用作顶级中的单独组件,就好像它是一个。对我来说很有用。我甚至都不想尝试,但它很有魅力。非常感谢。
JInternalFrame internalFrame = new JInternalFrame() {
@Override
public void setUI(InternalFrameUI ui) {
super.setUI(ui); // this gets called internally when updating the ui and makes the northPane reappear
BasicInternalFrameUI frameUI = (BasicInternalFrameUI) getUI(); // so...
if (frameUI != null) frameUI.setNorthPane(null); // lets get rid of it
}
};