JDesktopPane placement

2019-07-02 08:06发布

I have a JDesktopPane and want to display JInternalFrames in a grid style without overlaying frames. The dymensions of the frames will vary so their location should be assigned dynamically. I could store the coordinates of the last placed frame but frames can be moved, minimized or closed.. Is their an easy way of placing internal frames in a tidy way? e.g., using a Layout?

2条回答
祖国的老花朵
2楼-- · 2019-07-02 08:42

Here's an example that may offer some guidance. It uses setLocation() and an offset.

查看更多
【Aperson】
3楼-- · 2019-07-02 08:48

The DesktopManager class is responsible for managing the internal frames.

You should be able to override the openFrame() method to initially position the frame when it is added to the desktop.

There are also methods on dragging that you might be able to override to prevent the overlapping of frames.

查看更多
登录 后发表回答