I have create and internal frame which has been added to a frame but when I run it I find that the internal frame does not have any max,min,close,etc. I have not undecorated it and I have tried a couple of things like the look and feel and undecorated but nothing seems to fix it.

Here is my code (frame is the internal frame and outFrame is the JFrame):

 //Adding everything to contentPane.
    contentPane.add(label);
    contentPane.add(width);
    contentPane.add(textWidth);
    contentPane.add(height);
    contentPane.add(textHeight);
    contentPane.add(box);
    contentPane.add(bOpen);

    //Adding contentPane to the frame. 
    frame.add(contentPane);
    frame.setSize(500, 400);
    //frame.setClosable(true);
    frame.setVisible(true);

    //frame.setBorder(border);
    outFrame.add(frame);
    outFrame.setVisible(true);
有帮助吗?

解决方案

"the internal frame does not have any max,min,close,etc."

Look at the JInternalFrame API and see How to use Internal Frames.

You need to set the iconifiable, maximizable, and closable properties, as by default, they are set to false

  • public boolean setMaximizable(boolean b)

  • public void setIconifiable(boolean b)

  • public void setClosable(boolean b)

Or construct the frame with those values

public JInternalFrame(String title,
                      boolean resizable,
                      boolean closable,
                      boolean maximizable,
                      boolean iconifiable)

Setting the values to true will give you your buttons to close, maximize, and iconify the frame

"I have create and internal frame which has been added to a frame"

JInternalFrames are meant to used with and added to JDesktopPanes not the JFrames. See the link above I provided on how to use internal frames

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top