2

我正在尝试重现像 osx lion 的客户端这样的邮件客户端。所以我必须做类似的事情:

osx lion 的客户端邮件

我不知道这样做的最佳布局解决方案是什么..有人可以给我一些建议吗?谢谢!!!

4

3 回答 3

5

The solution would be to use a number of different layouts and components, nested within each other until you have built up the overall layout you are looking for. Typically you would use JPanels for each of the nested areas, and perhaps a JSplitPane for the resizable window areas.

You'll may find you need to write (or find in a 3rd party library library) a number of custom components for specific features.

At a guess, you could do most of the mail client layout with a combination of BorderLayout and GridBagLayout. But you might also want to consider MigLayout, which is a great general purpose layout manager that is very flexible.

If you haven't done so alredy, you should do the excellent Java Swing Tutorials

P.S. WindowBuilder is a great tool for quickly prototyping, but for more complex GUI designs like this I think you are ultimately better hand coding them.

于 2012-05-31T15:43:10.453 回答
1

这是您使用 JSplitPane 的目的。如果您不希望用户能够调整左右之间的划分大小,您可以使用 BorderLayout 左侧的工作方式如下:

panel = new JPanel( new BorderLayout() );
panel.add( new LeftPanel(), BorderLayout.WEST );
panel.add( new CentralPanel(), BorderLayout.CENTER );

这样,LeftPanel 将根据其首选宽度调整大小,并且中心将被赋予剩余的宽度和高度,因此它会随着用户增大和缩小窗口而自行调整大小,但左面板将是固定宽度并在高度。

如果您只是想知道通用布局 TableLayout 是迄今为止最简单还是最灵活的布局。使用它可以解决的布局问题并不多,而且它易于理解(相对于 SpringLayout、GroupedLayout 等)并且比 GridBagLayout 更少的代码和更强大的功能。

http://java.sun.com/products/jfc/tsc/articles/tablelayout/

但是对于您描述的问题,我认为您不必使用它。

于 2012-05-31T15:50:20.637 回答
1

总体而言,对于该屏幕截图,水平框布局可能是您所追求的(从左到右布置组件以填充空间。)

不过,您可能需要在其中嵌套其他布局,就像使用大多数合理大小的 UI 一样。

于 2012-05-31T15:40:08.060 回答