我在網上找到了一些代碼,我編輯了一下。我想隱藏JInternalFrame的標題欄。隱藏JInternalFrame的標題欄? -java
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);
問題是標題欄並未因某些原因而被隱藏。 謝謝。
不錯,這是正確的答案,不像.setUI(null)!我還在某處看到,在某些事件發生後(如最小化窗口),您可能需要重新執行此操作。 –
這是正確的答案。與'frame.setBorder(null);'結合使用['JInternalFrame'](https://docs.oracle.com/javase/8/docs/api/javax/swing/JInternalFrame.html )作爲頂級['JFrame'](http://docs.oracle.com/javase/8/docs/api/javax/swing/JFrame.html)中的獨奏組件,就好像它是['JPanel '](http://docs.oracle.com/javase/8/docs/api/javax/swing/JPanel.html)。 – vallismortis
爲我工作。我甚至不會嘗試,但像魅力一樣。謝謝。 – George