GridBag Layout or Absolute Positioning?

岁酱吖の 提交于 2019-12-24 02:14:14

问题


I'm working on a piece of code where several imageIcons will overlap several other imageIcons. imageIcons in the foreground will stay the same while imageIcons in the background will change to different imageIcons

I don't usually have the best luck with layouts. Components will move when I adjust the frame size, for instance. Also, when I add one object and then add another object, the second object will "push" the other object right (or wherever the particular layout is designed to put the next component.

Oracle's website stresses the importance to use a layout manager whenever possible (for sizing/resizing reasons). Would this be one of those cases where I would use Aboslute Positioning over the GridBag layout?


回答1:


If a container holds components whose size is not affected by the container's size or by font, look-and-feel, or language changes, then absolute positioning might make sense.Although it is possible to do without a layout manager, you should use a layout manager if at all possible. A layout manager makes it easier to adjust to look-and-feel-dependent component appearances, to different font sizes, to a container's changing size, and to different locales.[According to Oracle.com]

Look at this link, may be this can help you.

http://www.leepoint.net/notes-java/GUI/layouts/60gridbaglayout.html



来源:https://stackoverflow.com/questions/15846977/gridbag-layout-or-absolute-positioning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!