java中jframe的add方法
为什么下面两个语句的效果都能编译通过?正确的不是add(按钮,位置)吗?为什么add(位置,按钮)都可以?c.add(newJButton("我是按钮"),BorderL...
为什么下面两个语句的效果都能编译通过?
正确的不是 add(按钮,位置) 吗?
为什么 add(位置,按钮) 都可以?
c.add(new JButton("我是按钮"),BorderLayout.CENTER);
c.add(BorderLayout.CENTER,new JButton("我是按钮")); 展开
正确的不是 add(按钮,位置) 吗?
为什么 add(位置,按钮) 都可以?
c.add(new JButton("我是按钮"),BorderLayout.CENTER);
c.add(BorderLayout.CENTER,new JButton("我是按钮")); 展开
推荐于2016-08-12
展开全部
/闭唤链**
* Adds the specified component to the end of this container.
* Also notifies the layout manager to add the component to
* this container's layout using the specified constraints object.
* This is a convenience method for {@link #addImpl}.
* <p>
* Note: If a component has been added to a container that
* has been displayed, <code>validate</code> must be
* called on that container to display the new component.
* If multiple components are being added, you can improve
* efficiency by calling <code>validate</code> only once,
* after all the components have been added.
*
* @param comp the component to be added
* @param constraints an object expressing
* layout contraints for this component
* @exception NullPointerException if {@code comp} is {@code null}
* @see #addImpl
* @see #validate
* @see javax.swing.JComponent#revalidate()
* @see LayoutManager
* @since JDK1.1
*/轿孙
public void add(Component comp, Object constraints) {
addImpl(comp, constraints, -1);
}
/**
* Adds the specified component to this container.
* This is a convenience method for {@link #addImpl}.
* <链陵p>
* This method is obsolete as of 1.1. Please use the
* method <code>add(Component, Object)</code> instead.
* @exception NullPointerException if {@code comp} is {@code null}
* @see #add(Component, Object)
*/
public Component add(String name, Component comp) {
addImpl(comp, name, -1);
return comp;
}
看源码。
* Adds the specified component to the end of this container.
* Also notifies the layout manager to add the component to
* this container's layout using the specified constraints object.
* This is a convenience method for {@link #addImpl}.
* <p>
* Note: If a component has been added to a container that
* has been displayed, <code>validate</code> must be
* called on that container to display the new component.
* If multiple components are being added, you can improve
* efficiency by calling <code>validate</code> only once,
* after all the components have been added.
*
* @param comp the component to be added
* @param constraints an object expressing
* layout contraints for this component
* @exception NullPointerException if {@code comp} is {@code null}
* @see #addImpl
* @see #validate
* @see javax.swing.JComponent#revalidate()
* @see LayoutManager
* @since JDK1.1
*/轿孙
public void add(Component comp, Object constraints) {
addImpl(comp, constraints, -1);
}
/**
* Adds the specified component to this container.
* This is a convenience method for {@link #addImpl}.
* <链陵p>
* This method is obsolete as of 1.1. Please use the
* method <code>add(Component, Object)</code> instead.
* @exception NullPointerException if {@code comp} is {@code null}
* @see #add(Component, Object)
*/
public Component add(String name, Component comp) {
addImpl(comp, name, -1);
return comp;
}
看源码。
追问
看不懂啊,能不能解释一下啊
追答
给你份中文的api自己看吧
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询