0

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.

enter image description here

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();
    }
}
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
  • Not infront on my mac at the mo, but do you mean you want to get ride of the frame?? Can you post a screen shot? – MadProgrammer Jul 12 '12 at 23:36
  • grr, tried to upload an image but it wouldn't work. basically, if you maximize the JInternalFrame inside the JDesktop, there is still blue that you can see (you can still see the desktop)...the JInternalFrame does not actually fill up the entire JDesktop. I'm trying to get it so that it DOES fill up the entire JDesktop – CodeGuy Jul 13 '12 at 01:00
  • Ahh, so you want it so that the "frame" is removed. This is "none" trival problem, as you need to take into account the frames menu bar. I'll have a play around with some ideas and see what I come up with... – MadProgrammer Jul 13 '12 at 02:09

3 Answers3

2

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

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • that problem does not relate to this question, unfortunately. – CodeGuy Jul 13 '12 at 17:10
  • 1
    Really? From what i can tell, The reason the internal frame isn't filling the desktop area is because it's taking into account the shadow insets around the frame – MadProgrammer Jul 13 '12 at 17:15
  • @CodeGuy: The client property works for me in this [example](http://stackoverflow.com/a/8199839/230513); +1; – trashgod Jul 13 '12 at 18:12
1

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

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Tyr this

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