簡體   English   中英

JDesktopPane邊界-JInternalFrame沒有填滿整個桌面

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

我希望JDesktopPane能夠最大化其中的JInternalFrames並完全遮擋JDesktopPane的藍色背景(至少在Mac上為藍色)。 如果運行此演示,您將看到,如果最大化JInternalFrame ,它不會占用整個JDesktopPane 如何設置JDesktopPane ,以便JInternalFrame占用整個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();
    }
}

您可以在Google上找到驚人的東西。 我自己還沒有檢查過,但這可能會有所幫助

通過Aqua外觀禁用JInternalFrames周圍的陰影

您可以覆蓋JDesktopPane使用的DesktopManager maximizeFrame()方法。 有一個相關的例子在這里

提爾這個

// 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