2012-07-12 50 views
0

我想我的JDesktopPane是這樣的,它內部的JInternalFrames可以最大化,並完全阻止藍色背景(至少在Mac上是藍色的) JDesktopPane。如果你運行這個演示,你會看到如果你最大化JInternalFrame,它不會佔用整個JDesktopPane如何設置JDesktopPane以使JInternalFrame佔用整個JDesktopPaneJDesktopPane邊界 - JInternalFrame的沒有填滿整個桌面

在這張圖片中,我運行了下面的代碼並按下了JInternalFrame上的最大化按鈕,但JDesktopPane上仍然顯示「藍色」。

enter image description here

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(); 
    } 
} 
+0

不盈我在莫MAC,但你的意思是你想要得到的騎幀??你能發佈一個屏幕截圖嗎? – MadProgrammer 2012-07-12 23:36:04

+0

grr,試圖上傳圖片,但它不起作用。基本上,如果您最大化JDesktop內部的JInternalFrame,仍然可以看到藍色(您仍然可以看到桌面)... JInternalFrame實際上並沒有填滿整個JDesktop。我試圖弄清楚它是否填滿了整個JDesktop – CodeGuy 2012-07-13 01:00:24

+0

啊,所以你需要它,以便「框架」被刪除。這是「無」trival問題,因爲你需要考慮框架菜單欄。我會玩一些想法,看看我想出了什麼... – MadProgrammer 2012-07-13 02:09:18

回答

2

這是驚人的,你可以找到谷歌。我沒有檢查這一點我自己,但是這可能幫助

Disabling the shadow around JInternalFrames with the Aqua Look and Feel

+0

不幸的是,這個問題並沒有涉及到這個問題。 – CodeGuy 2012-07-13 17:10:11

+1

真的嗎?從我所知道的,內部框架不填充桌面區域的原因是因爲它考慮了框架周圍的陰影插槽 – MadProgrammer 2012-07-13 17:15:50

+0

@CodeGuy:客戶端屬性適用於此[示例](http:// stackoverflow.com/a/8199839/230513); +1; – trashgod 2012-07-13 18:12:08

1

您可以覆蓋DesktopManagermaximizeFrame()方法,通過您的JDesktopPane使用。有一個相關示例here

0

酪氨酸這

// Add internal frame to desktop 
JDesktopPane desktop = new JDesktopPane(); 
desktop.add(iframe); 
iframe.setMaximum(true); 
相關問題