我想我的JDesktopPane
是這樣的,它內部的JInternalFrames
可以最大化,並完全阻止藍色背景(至少在Mac上是藍色的) JDesktopPane
。如果你運行這個演示,你會看到如果你最大化JInternalFrame
,它不會佔用整個JDesktopPane
。 如何設置JDesktopPane
以使JInternalFrame
佔用整個JDesktopPane?JDesktopPane邊界 - JInternalFrame的沒有填滿整個桌面
在這張圖片中,我運行了下面的代碼並按下了JInternalFrame上的最大化按鈕,但JDesktopPane上仍然顯示「藍色」。
import java.awt.BorderLayout;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JTextArea;
/**
*
* @author Robert
*/
public class Temp {
Temp() {
boolean resizable = true;
boolean closeable = true;
boolean maximizable = true;
boolean iconifiable = true;
String title = "Frame Title";
JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable);
// Set an initial size
int width = 200;
int height = 50;
iframe.setSize(width, height);
// By default, internal frames are not visible; make it visible
iframe.setVisible(true);
// Add components to internal frame...
iframe.getContentPane().add(new JTextArea());
// Add internal frame to desktop
JDesktopPane desktop = new JDesktopPane();
desktop.add(iframe);
// Display the desktop in a top-level frame
JFrame frame = new JFrame();
frame.getContentPane().add(desktop, BorderLayout.CENTER);
frame.setSize(300, 300);
frame.setVisible(true);
}
public static void main (String[] args) {
new Temp();
}
}
不盈我在莫MAC,但你的意思是你想要得到的騎幀??你能發佈一個屏幕截圖嗎? – MadProgrammer 2012-07-12 23:36:04
grr,試圖上傳圖片,但它不起作用。基本上,如果您最大化JDesktop內部的JInternalFrame,仍然可以看到藍色(您仍然可以看到桌面)... JInternalFrame實際上並沒有填滿整個JDesktop。我試圖弄清楚它是否填滿了整個JDesktop – CodeGuy 2012-07-13 01:00:24
啊,所以你需要它,以便「框架」被刪除。這是「無」trival問題,因爲你需要考慮框架菜單欄。我會玩一些想法,看看我想出了什麼... – MadProgrammer 2012-07-13 02:09:18