当前位置: 技术问答>java相关
一个初学者的问题,关于pack()
来源: 互联网 发布时间:2015-06-30
本文导语: 请问下面的代码中pack()是做什么用的? public static void main(String[] arguments) { Slider frame = new Slider(); frame.pack(); // 请问这个是什么意思?? frame.setVisible(true); } | 不会有什么结果,不...
请问下面的代码中pack()是做什么用的?
public static void main(String[] arguments) {
Slider frame = new Slider();
frame.pack(); // 请问这个是什么意思??
frame.setVisible(true);
}
public static void main(String[] arguments) {
Slider frame = new Slider();
frame.pack(); // 请问这个是什么意思??
frame.setVisible(true);
}
|
不会有什么结果,不过你创建的窗口不会正常显示大大小。
下面是这个函数的解释:)
public void pack()
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.
See Also:
Component.isDisplayable()
下面是这个函数的解释:)
public void pack()
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.
See Also:
Component.isDisplayable()