我希望我的 JDesktopPane
能够最大化其中的 JInternalFrames
并完全遮挡蓝色背景(好吧,蓝色背景)至少在 Mac 上)的 JDesktopPane
。如果运行此演示,您会发现,如果最大化 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();
}
}
最佳答案
你在谷歌上能找到的东西真是太神奇了。我自己没有检查过,但这可能会有所帮助
Disabling the shadow around JInternalFrames with the Aqua Look and Feel
关于java - JDesktopPane 边界 - JInternalFrame 未填满整个桌面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11461739/