Re: [問題] 寫Java時的問題
※ 引述《thirddawn.bbs@ptt.cc (白夜)》之銘言:
> 因為是新手上路,所以問的問題說不定很白癡請大家多多包含
> 目前在寫一段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.
--
╭┼ Origin: 台中師院˙清蘅夢土 mse.ntcu.edu.tw
┼┘ Author: chuangjo 從 219-81-255-142.static.tfn.net.tw 發表
java 近期熱門文章
PTT數位生活區 即時熱門文章