我正在学习秋千,我对这一行感到困惑。
GroupLayout layout=new GroupLayout(getContentPane());现在我有两个问题
发布于 2013-08-13 09:49:24
getContentPane()返回什么?
它返回组件的内容窗格
你可以读更多关于它的这里
为什么我们要将它传递给GroupLayout,我的意思是getContentPane()是如何用于组布局的
这就是GroupLayout的实现方式。
构造者:
GroupLayout(Container host)为指定的容器创建一个GroupLayout。请转接javadoc获得更多信息
发布于 2013-08-13 09:51:00
功能是
/**
* Creates a {@code GroupLayout} for the specified {@code Container}.
*
* @param host the {@code Container} the {@code GroupLayout} is
* the {@code LayoutManager} for
* @throws IllegalArgumentException if host is {@code null}
*/
public GroupLayout(Container host) {
if (host == null) {
throw new IllegalArgumentException("Container must be non-null");
}
honorsVisibility = true;
this.host = host;
setHorizontalGroup(createParallelGroup(Alignment.LEADING, true));
setVerticalGroup(createParallelGroup(Alignment.LEADING, true));
componentInfos = new HashMap<Component,ComponentInfo>();
tmpParallelSet = new HashSet<Spring>();
}此构造函数语句为指定容器创建GroupLayout。
https://stackoverflow.com/questions/18205647
复制相似问题