看板java
标 题Re: [问题] 写Java时的问题
发信站清蘅梦土 (Sun Jun 25 16:42:18 2006)
转信站ptt!ctu-reader!news.nctu!NTCTCTMSE
※ 引述《[email protected] (白夜)》之铭言:
> 因为是新手上路,所以问的问题说不定很白痴请大家多多包含
> 目前在写一段GUI的东西
> 在一个Frame里面要有两个Label(左边一个小的,右边一个大的)
> 是希望能够在作出像是网页的那种
> 左边点了按钮之後右边可以跑出对应的Label页
> 可是我在左边按钮的event Listener里写了要整个container去add右边的Label
> 执行起来时却没有反应Orz...
> 请问一下是不能这样写吗?还是说要怎麽样才可以多次更新右边那块Label
> 而左边都可以保持不动呢?
> 谢谢
public Component add(Component comp)
Appends the specified component to the end of this container.
This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int).
Note: If a component has been added to a container that has been displayed,
validate must be called on that container to display the new component.
If multiple components are being added, you can improve efficiency by calling
validate only once, after all the components have been added.
以上是API中关於add的部分说明,其中有提到如果加入多个Component时要如何处理。
public void validate()
Validates this container and all of its subcomponents.
The validate method is used to cause a container to lay out its subcomponents
again. It should be invoked when this container's subcomponents are modified
(added to or removed from the container, or layout-related information
changed) after the container has been displayed.
--
╭┼ Or
igin:
台中师院˙清蘅梦土 mse.ntcu.edu.tw
┼┘ A
uthor:
chuangjo 从 219-81-255-142.static.tfn.net.tw 发表