简体   繁体   English

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

[英]JDesktopPane boundary - JInternalFrame's not filling up entire desktop

I'd like to have my JDesktopPane be such that JInternalFrames that are inside of it can be maximized and fully block out the blue background (well, blue on a Mac at least) of the JDesktopPane . 我希望JDesktopPane能够最大化其中的JInternalFrames并完全遮挡JDesktopPane的蓝色背景(至少在Mac上为蓝色)。 If you run this demo, you'll see that if you maximize the JInternalFrame , it does not take up the entire JDesktopPane . 如果运行此演示,您将看到,如果最大化JInternalFrame ,它不会占用整个JDesktopPane How can I get the JDesktopPane set up so that the JInternalFrame does take up the entire JDesktopPane ? 如何设置JDesktopPane ,以便JInternalFrame占用整个JDesktopPane

In this image, I have ran the code below and have pressed the maximize button on the JInternalFrame, yet there is still "blue" showing on the JDesktopPane. 在此图像中,我运行了以下代码,并按下了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();
    }
}

It's amazing what you can find on google. 您可以在Google上找到惊人的东西。 I've not checked this out myself, but this might help 我自己还没有检查过,但这可能会有所帮助

Disabling the shadow around JInternalFrames with the Aqua Look and Feel 通过Aqua外观禁用JInternalFrames周围的阴影

You can override the maximizeFrame() method of the DesktopManager used by your JDesktopPane . 您可以覆盖JDesktopPane使用的DesktopManager maximizeFrame()方法。 There's a related example here . 有一个相关的例子在这里

Tyr this 提尔这个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM