简体   繁体   中英

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 . If you run this demo, you'll see that if you maximize the JInternalFrame , it does not take up the entire JDesktopPane . How can I get the JDesktopPane set up so that the JInternalFrame does take up the entire 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.

在此处输入图片说明

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. I've not checked this out myself, but this might help

Disabling the shadow around JInternalFrames with the Aqua Look and Feel

You can override the maximizeFrame() method of the DesktopManager used by your JDesktopPane . There's a related example here .

Tyr this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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