JDesktopPane边界 - JInternalFrame没有填满整个桌面

时间:2012-07-12 22:37:05

标签: java swing jinternalframe jdesktoppane

我希望我的JDesktopPane能够使JInternalFrames内的JDesktopPane最大化并完全阻挡蓝色背景(至少在Mac上为蓝色) JInternalFrame。如果您运行此演示,您会看到如果您最大化JDesktopPane,则不会占用整个JDesktopPane如何设置JInternalFrame以便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(); } } 占用整个JDesktopPane

在这张图片中,我运行了下面的代码并按下了JInternalFrame上的最大化按钮,但JDesktopPane上仍然显示“蓝色”。

enter image description here

{{1}}

3 个答案:

答案 0 :(得分:2)

你可以在谷歌上找到它真是太棒了。我自己没有检查过,但这可能会有所帮助

Disabling the shadow around JInternalFrames with the Aqua Look and Feel

答案 1 :(得分:1)

您可以覆盖maximizeFrame()使用的DesktopManager JDesktopPane方法。有一个相关的例子here

答案 2 :(得分:0)

Tyr this

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