锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品一区二区三区蜜桃视频 ,成人99免费视频,午夜精品网站http://www.aygfsteel.com/Pragmatic/best practiceszh-cnWed, 18 Jun 2025 19:25:36 GMTWed, 18 Jun 2025 19:25:36 GMT60Mail list 綺鵑夛紞JCoverage is dead?http://www.aygfsteel.com/Pragmatic/archive/2006/09/16/70009.html鑲栭箯鑲栭箯Sat, 16 Sep 2006 01:59:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/09/16/70009.htmlhttp://www.aygfsteel.com/Pragmatic/comments/70009.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/09/16/70009.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/70009.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/70009.html

avg_3000 wrote:
> Hi,
>
> Can you suggest a tutorial site for junit and jcoverage that covers
> from the grassroot level since I have no idea on how to use this tools
> in java.

jcoverage is as good as dead. Use Cobertura, which is its replacement.
Cobertura has documentation for running it in Ant; it's even easier in
Maven.
Take a look at <http://cobertura.sourceforge.net/anttaskreference.html>,
since that's what Google would probably have pulled up if you'd searched.

緇撳悎浣跨敤JUnit鍜孋obertura鍙兘鏄笉閿欑殑閫夋嫨銆?/p>

鑲栭箯 2006-09-16 09:59 鍙戣〃璇勮
]]>
璁捐妯″紡婕皥錛?錛夛細Factory Method鍙互鐢╯tatic瀹炵幇鍚楋紵http://www.aygfsteel.com/Pragmatic/archive/2006/09/03/ramble-1.html鑲栭箯鑲栭箯Sun, 03 Sep 2006 06:21:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/09/03/ramble-1.htmlhttp://www.aygfsteel.com/Pragmatic/comments/67400.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/09/03/ramble-1.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/67400.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/67400.html銆旀湰绔欏壇绔欏彂甯冿紝涓葷珯錛歞esignpatterns.cnblogs.com銆?/p>

鈼嬨傝儗鏅笌鑳屾櫙鐭ヨ瘑

榪欐槸鏄ㄥぉ鍦≦Q涓婁婦鐨勪竴涓緥瀛愩傛湰鏂囧茍涓嶆槸浠庡ご璁睩actory Method妯″紡錛屼粎瀵瑰叾瀹炵幇緇嗚妭榪涜璁ㄨ銆傚叧浜庤繖涓ā寮忓彲浠ュ弬鑰?a target="_blank">wayfarer鍜?a target="_blank">鍚曢渿瀹?/a>鐨勬枃绔犮?/p>

涓銆傚垎鏋?/p>

鍥犱負Factory Method錛堝ぇ鍐欑殑Factory Method琛ㄧず妯″紡鍚嶇О錛夋ā寮忕殑涓涓洰鐨勫氨鏄嬌寰楀垱寤鴻涓猴紙factory method錛夛紙灝忓啓鐨刦actory method琛ㄧず鍒涘緩琛屼負鏂規硶錛夋娊璞″寲錛岀敱瀛愮被瀹炵幇錛屼粠鑰屽鏄撴墿灞曘備竴涓函鐨凢actory Method妯″紡錛屽叾factory method鏄笉鑳界敤static鏉ュ疄鐜扮殑銆傞氬父Simple Factory妯″紡鎵嶄細鐢眘tatic鏉ュ疄鐜般?/p>

浣嗘槸錛屼竴涓狥actory鎷ユ湁涓涓猻tatic鐨勫垱寤烘柟娉曟槸寰堣浜虹殑銆傜敤鎴峰湪浠諱綍鏃跺欏彧瑕佺敤綾誨悕錛團actory鐨勭被鍚嶏級鏃㈠彲浠ュ垱寤哄嚭闇瑕佺殑Product銆?a target="_blank">wayfarer聽鐨勬枃绔犳渶鍚庣粰鍑虹殑DotNet鐨勫疄鐜伴儴鍒嗗氨鏄繖鏍風殑渚嬪瓙銆傚悤闇囧畤鐨勫彟涓綃?a >鏂囩珷聽錛堝叧浜嶴imple Factory妯″紡錛夌殑鍥炲涓?a >Walkdan緇欏嚭鐨勮В鍐蟲柟妗堜篃鏄繖鏍風殑銆備粠鏈川涓婏紝榪欎袱涓緥瀛愰兘涓嶆槸綰殑Factory Method妯″紡鎴栬匰imple Factory妯″紡錛岃屾槸Simple Factory妯″紡鍜孎actory Method妯″紡鐨勭粍鍚堝簲鐢ㄣ?/p>

寮曠敤Walkdan鐨勫洖澶嶏細

Simple Factory鏈澶х殑濂藉鏄妸鍙樺寲闆嗕腑鍒頒簡涓澶勩傚彟澶栵紝LightSimpleFactory.Create()閲岄潰鐨勪緷璧栧叧緋諱篃鍙互娑堥櫎錛屾垜鐨勫仛娉曟槸:

1. 澹版槑鏋勯犲瓙

public interface聽ILightCreator
{
聽聽聽聽Light聽Create();
}

public class聽BulbLightCreator:聽ILightCreator
{
public聽Light聽Create()
聽聽聽聽{
return new聽BulbLight();
聽聽聽聽}
}
.

2. 娉ㄥ唽鏋勯犲瓙

creators.Register("Bulb",聽new聽BulbLightCreator());
creators.Register("Tube",聽new聽TubeLightCreator());
.

3.聽Simple Factory涓垱寤哄璞÷?/em>

public class聽LightSimpleFactory.Create(string聽lightType)
{
聽聽聽聽ILightCreator聽creator聽=聽creators.Find(lightType);
return聽creator.Create();
}

鏋勯犲瓙鍏跺疄灝辨槸Factory Method銆傝繖鏍? 閫氳繃娉ㄥ唽鏋勯犲瓙錛?.涓師鏉ョ殑switch()榪囩▼琚秷闄わ紝渚濊禆鍏崇郴闅忎箣瑙i櫎銆傚叾涓殑Register(), Find()瀹規槗鐞嗚В錛屾柟娉曞氨涓嶅啓浜嗐?/em>

鏂扮殑綾誨瀷鍙氳繃鏂版敞鍐屾瀯閫犲瓙鏉ュ疄鐜版墿灞曘傚綋鐒?涓殑娉ㄥ唽浠g爜浠呬粎鏄ず渚嬶紝瀹屽叏鍙互鏀懼埌閰嶇疆鏂囦歡涓幓瀹炵幇錛屾瘮濡傦細

<lightCreators>
<add聽name="Bulb"聽type="BulbLightCreator,"/>
<add聽name="Tube"聽type="TubeLightCreator,"/>
</lightCreators>

鍏禝LightCreator緇ф壙浣撶郴錛屾槸Factory Method妯″紡銆侺ightSimpleFactory鍜宑reators鐨勫叧緋籛alkdan娌℃湁璇存槑錛屼篃鍙疄鐜頒負Strategy妯″紡銆?/p>

浜屻傚紩鐢抽棶棰?/p>

  1. 妯″紡涓璮actory method涓瀹氳鏄娊璞$殑鍚楋紵 NO.浣犲彲浠ュ畾涔変竴涓粯璁ょ殑鏂規硶錛岀敓浜ф煇縐峆roduct銆傝繖鏍峰嵆浣縁actory娌℃湁瀛愮被涔熷彲浠ョ敓浜ц繖縐嶉粯璁や駭鍝併傞氬父榪欑鎯呭喌涓婩actory鏄竴涓帴鍙o紝鐒跺悗瀹氫箟涓涓狟asicFactory鏉ョ敓浜asicProduct銆傚叾浠栫殑Factory鐢盉asicFactory媧劇敓銆傛敞鎰忥紝寰寰Factory鍜孭roduct鏄鉤琛岀殑緇ф壙緇撴瀯銆?
  2. Factory Method瑙h︿簡client鍜宑oncreteProduct錛屾槸涓嶆槸鍙堝紩鍏ヤ簡client鍜宑oncreteFactory鐨勮﹀悎錛?榪欎釜闂寰堝ソ錛岀瓟妗堟槸鍙兘錛堛奾ead first design patterns銆嬩竴涔︿腑鐨勪緥瀛愬氨鏈夎繖涓棶棰橈級錛屼絾鏄痗lient绔笉搴旇渚濊禆concreteFactory銆傚鏋滀緷璧朿oncreteFactory錛岄偅鐪熸槸鐢昏泧娣昏凍浜嗭紙瑙?a target="_blank">wayfarer鐨勬枃绔狅級銆?
  3. Factory Method妯″紡鐨勫ソ澶勬湁鍝簺錛?
    1. 灝佽浜嗗璞$殑鍒涘緩銆傚璞$殑鍒涘緩濡傛灉浣跨敤new鏉ュ畬鎴愶紝鍒欎笌瀹炵幇綾伙紙concreteProduct錛夋槸绱ц﹀悎鐨勩侳actory Method鐨勫垱寤鴻涓篺actory method錛岃繑鍥濸roduct鎺ュ彛錛屼粠鑰岃В鑰︿簡client鍜宑oncreteProduct銆?
    2. 鏄撲簬鎵╁睍銆傜浉瀵逛簬Simple Factory妯″紡錛孎actory Method妯″紡鍙互閫氳繃媧劇敓榪涜鎵╁睍銆?/li>

涓夈傜粨璁?/p>

涓涓函鐨凢actory Method妯″紡鍏秄actory method涓嶅彲浠ョ敤static瀹炵幇錛岄氳繃涓庡叾浠栨ā寮忕粨鍚堜嬌鐢ㄥ彲浠ヨ繘琛屽彉閫氥傝屼笖閫氬父鎯呭喌涓婩actory Method妯″紡閮戒細涓庡叾浠栨ā寮忕浉緇撳悎銆侫bstract Factory妯″紡閫氬父灝辨槸鐢‵actory Method妯″紡鏉ュ疄鐜般?/p>

鑲栭箯 2006-09-03 14:21 鍙戣〃璇勮
]]>
嬈㈣繋鍔犲叆璁捐妯″紡QQ緹わ細26227899http://www.aygfsteel.com/Pragmatic/archive/2006/09/02/67318.html鑲栭箯鑲栭箯Sat, 02 Sep 2006 14:05:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/09/02/67318.htmlhttp://www.aygfsteel.com/Pragmatic/comments/67318.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/09/02/67318.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/67318.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/67318.html1.璇諱功蹇冨緱浜ゆ祦錛屽ぇ瀹跺彲浠ョ浉綰︿竴璧瘋涔︿簰鐩鎬氦嫻?br />2.鎶鏈氦嫻侊紝浠諱綍涓庤璁℃ā寮忕浉鍏籌紝鍖呮嫭閲嶆瀯錛屾祴璇曢┍鍔紝鏁忔嵎寮鍙戠瓑錛屽紑鍙戜腑閬囧埌鐨勯棶棰樸?br />瑕佹眰鑷沖皯鍙戣〃榪囦竴綃囧叧浜庤璁℃ā寮忕殑鏂囩珷鎵嶅彲浠ュ姞鍏ャ?br />http://group.qq.com/group_index.shtml?funcid=1&groupid=26227899
鍙嬫儏鎻愮ず錛氬鏋滀綘鍙墦綆椻滃惉鈥濓紝涓嶆墦綆椻滆鈥濇垨鑰呪滈棶鈥濓紝瀵逛綘鐨勫府鍔╀細灝忕殑澶氥?br />

鑲栭箯 2006-09-02 22:05 鍙戣〃璇勮
]]>
Effective Java 闃呰絎旇錛嶏紞絎竴绔狅紝寮曡█http://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64619.html鑲栭箯鑲栭箯Sun, 20 Aug 2006 06:12:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64619.htmlhttp://www.aygfsteel.com/Pragmatic/comments/64619.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64619.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/64619.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/64619.html鏈功涓殑澶у鏁板師鍒欐簮浜庡皯鏁板嚑鏉″熀鏈師鍒欍?/p>

1.娓呮櫚鎬у拰綆浠嬫ф槸鏈涓洪噸瑕佺殑錛氫竴涓ā鍧楃殑鐢ㄦ埛姘歌繙涔熶笉搴旇琚ā鍧楃殑琛屼負鎵榪鋒儜錛堥偅鏍峰氨涓嶆竻鏅頒簡錛夛紱妯″潡瑕佸敖鍙兘鐨勫皬錛屼絾鍙堜笉鑳藉お灝忋旀湳璇ā鍧楋紙module錛夊湪鏈功涓殑鐢ㄦ硶錛屾槸鎸囦換浣曞彲閲嶇敤鐨勮蔣浠剁粍浠訛紝浠庡崟涓柟娉曪紝鍒板寘鍚涓寘鐨勫鏉傜郴緇熼兘鍙互鏄竴涓ā鍧椼曘?/p>

2.浠g爜搴旇琚噸鐢紝鑰屼笉鏄鎷瘋礉銆?/p>

3.妯″潡涔嬮棿鐨勭浉渚濇у簲璇ュ敖鍙兘闄嶄綆鍒版渶灝忋?/p>

4.閿欒搴旇灝芥棭琚嫻嬪嚭鏉ワ紝鐞嗘兂鎯呭喌涓嬫槸鍦ㄧ紪璇戞椂鍒匯?/p>

鑲栭箯 2006-08-20 14:12 鍙戣〃璇勮
]]>
Temporary Post Used For Style Detection (afe811f5-b525-4432-b217-3d8a8e77d2d1)http://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64616.html鑲栭箯鑲栭箯Sun, 20 Aug 2006 06:02:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64616.htmlhttp://www.aygfsteel.com/Pragmatic/comments/64616.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/08/20/64616.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/64616.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/64616.htmlThis is a temporary post that was not deleted. Please delete this manually. (e6a97894-4dd8-4eed-8ba1-b291c8b2bc96)



鑲栭箯 2006-08-20 14:02 鍙戣〃璇勮
]]>
Java tips(3): Ant 瀵規枃浠跺悕鏄尯鍒嗗ぇ灝忓啓鐨?/title><link>http://www.aygfsteel.com/Pragmatic/archive/2006/07/27/java_tips_3.html</link><dc:creator>鑲栭箯</dc:creator><author>鑲栭箯</author><pubDate>Thu, 27 Jul 2006 08:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/Pragmatic/archive/2006/07/27/java_tips_3.html</guid><wfw:comment>http://www.aygfsteel.com/Pragmatic/comments/60375.html</wfw:comment><comments>http://www.aygfsteel.com/Pragmatic/archive/2006/07/27/java_tips_3.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Pragmatic/comments/commentRss/60375.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Pragmatic/services/trackbacks/60375.html</trackback:ping><description><![CDATA[Ant 瀵規枃浠跺悕鏄尯鍒嗗ぇ灝忓啓鐨?img src ="http://www.aygfsteel.com/Pragmatic/aggbug/60375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Pragmatic/" target="_blank">鑲栭箯</a> 2006-07-27 16:23 <a href="http://www.aygfsteel.com/Pragmatic/archive/2006/07/27/java_tips_3.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Java tips(2): 璁╀笉鍖呭惈瀛愮粨鐐圭殑TreeNode鐪嬩笂鍘誨儚鐖惰妭鐐?/title><link>http://www.aygfsteel.com/Pragmatic/archive/2006/07/18/java_tips_2.html</link><dc:creator>鑲栭箯</dc:creator><author>鑲栭箯</author><pubDate>Tue, 18 Jul 2006 01:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/Pragmatic/archive/2006/07/18/java_tips_2.html</guid><wfw:comment>http://www.aygfsteel.com/Pragmatic/comments/58691.html</wfw:comment><comments>http://www.aygfsteel.com/Pragmatic/archive/2006/07/18/java_tips_2.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Pragmatic/comments/commentRss/58691.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Pragmatic/services/trackbacks/58691.html</trackback:ping><description><![CDATA[ <font face="Courier New">0.寮曞瓙<br />閫氬父涓涓猅reeNode 錛圖efaultMutableTreeNode錛夊鏋滄病鏈夊瓙緇撶偣錛屽畠鐨勮妭鐐規樉紺轟負涓嶅彲灞曞紑鐨勮妭鐐癸紝鏈夋椂鍊欐垜浠笇鏈涘嵆浣胯鑺傜偣鏆傛椂娌℃湁瑁呰澆瀛愮粨鐐逛粛鐒舵樉紺轟負鍙睍寮鐨勮妭鐐癸紙濡傚浘<img height="10" alt="ParentNode.jpg" src="http://www.aygfsteel.com/images/blogjava_net/pragmatic/JTips/ParentNode.jpg" width="15" border="0" />錛夈傛瘮濡傦紝褰撳姞杞藉瓙緇撶偣姣旇緝鑰楁椂鎴栬呴渶瑕佸姩鎬佸埛鏂幫紝鍙互寤舵椂鍔犺澆瀛愮粨鐐癸紝鍗沖湪灞曞紑鑺傜偣鐨勬椂鍊欏啀鍘昏杞藉瓙緇撶偣銆?br />1.鐢辨潵鍙婅В鍐蟲柟妗?br />璇ュ睘鎬у彇鍐充簬錛孌efaultTreeModel鐨刬sLeaf鏂規硶</font>聽<br /><font face="Courier New"><pre style="BORDER-RIGHT: #000000 0.01mm solid; PADDING-RIGHT: 4px; BORDER-TOP: #000000 0.01mm solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #000000 0.01mm solid; LINE-HEIGHT: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #000000 0.01mm solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #ffffff"><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">聽聽聽 /** * Returns whether the specified node is a leaf node. * The way the test is performed depends on the * </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #e2ffe2"><code></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">askAllowsChildren</span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #e2ffe2"></code></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> setting. * * </span><span style="COLOR: #808080; TEXT-DECORATION: underline"><span style="FONT-WEIGHT: bold; COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">@param</span></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> node the node to check * </span><span style="COLOR: #808080; TEXT-DECORATION: underline"><span style="FONT-WEIGHT: bold; COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">@return</span></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> true if the node is a leaf node * * </span><span style="COLOR: #808080; TEXT-DECORATION: underline"><span style="FONT-WEIGHT: bold; COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">@see</span></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> #asksAllowsChildren * </span><span style="COLOR: #808080; TEXT-DECORATION: underline"><span style="FONT-WEIGHT: bold; COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">@see</span></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> TreeModel#isLeaf */ </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">public</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">boolean</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> isLeaf(Object node) { </span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">(</span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; BACKGROUND-COLOR: #ffffff">asksAllowsChildren) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">return</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> !((TreeNode)node).getAllowsChildren(); </span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">return</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> ((TreeNode)node).isLeaf(); }</span></pre><!--EndFragment-->鑰宎sksAllowsChildren鐢辨柟娉晄etAsksAllowsChildren璁懼畾<br /><pre style="BORDER-RIGHT: #000000 0.01mm solid; PADDING-RIGHT: 4px; BORDER-TOP: #000000 0.01mm solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #000000 0.01mm solid; LINE-HEIGHT: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #000000 0.01mm solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #ffffff"><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">聽聽聽 /** * Sets whether or not to test leafness by asking getAllowsChildren() * or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() * is messaged, otherwise isLeaf() is messaged. */ </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">public</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">void</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> setAsksAllowsChildren(</span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">boolean</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> newValue) { </span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; BACKGROUND-COLOR: #ffffff">asksAllowsChildren </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">= newValue; }</span></pre><!--EndFragment--></font><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"><font face="Courier New">娉ㄦ剰錛屽湪setRoot鏃跺彲浠ュ彧璁懼畾涓嬈?br /></font></span><pre style="BORDER-RIGHT: #000000 0.01mm solid; PADDING-RIGHT: 4px; BORDER-TOP: #000000 0.01mm solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #000000 0.01mm solid; LINE-HEIGHT: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #000000 0.01mm solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #ffffff"><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">聽聽聽聽聽聽 model.setRoot(root); </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">/* * Since nodes are added dynamically in this application, the only true * leaf nodes are nodes that don't allow children to be added. (By * default, askAllowsChildren is false and all nodes without children * are considered to be leaves.) * * But there's a complication: when the tree structure changes, JTree * pre-expands the root node unless it's a leaf. To avoid having the * root pre-expanded, we set askAllowsChildren *after* assigning the * new root. */ </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> model.setAsksAllowsChildren(</span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">true</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">);</span></pre><p><!--EndFragment--><font face="Courier New">鑰屽湪璋冪敤model.nodeStructureChanged(node)鍓嶅悗瑕佸垎鍒緗負false鍜宼rue銆傝繖鏄洜涓簄odeStructureChanged浼氳嚜鍔ㄧ殑璇曞浘灞曞紑鑺傜偣node錛屽鏋渋sLeaf榪斿洖涓篺alse銆傝瘯鎯籌紝asksAllowsChildren榪斿洖true錛屽垯涓涓粨鐐瑰嵆浣挎病鏈夊瓙緇撶偣錛屽彧瑕佽緗簡allowsChildren錛屽搴旂殑treeNodeModel鐨刬sLeaf灝變細榪斿洖true銆傜劧鑰屽綋鑷姩灞曞紑鑺傜偣鐨勬椂鍊欏彂鐜板茍娌℃湁瀛愮粨鐐癸紝褰撶劧灝變細鎶婂浘鏍?img height="10" alt="ParentNode.jpg" src="http://www.aygfsteel.com/images/blogjava_net/pragmatic/JTips/ParentNode.jpg" width="15" border="0" />鍘繪帀浜嗐傝屽厛鎶奱sksAllowsChildren璁句負false錛屽氨涓嶄細鍘昏瘯鍥懼睍寮璇ヨ妭鐐癸紝鐒跺悗璁句負true錛岃鑺傜偣灝變細鏄劇ず涓?img height="10" alt="ParentNode.jpg" src="http://www.aygfsteel.com/images/blogjava_net/pragmatic/JTips/ParentNode.jpg" width="15" border="0" />銆?/font>聽聽聽<br /></p><pre style="BORDER-RIGHT: #000000 0.01mm solid; PADDING-RIGHT: 4px; BORDER-TOP: #000000 0.01mm solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #000000 0.01mm solid; LINE-HEIGHT: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #000000 0.01mm solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #ffffff"><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">聽聽聽 /** * Determines whether or not this node is allowed to have children. * If </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #e2ffe2"><code></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">allows</span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #e2ffe2"></code></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> is false, all of this node's children are * removed. * </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #e2ffe2"><p> </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> * Note: By default, a node allows children. * * </span><span style="COLOR: #808080; TEXT-DECORATION: underline"><span style="FONT-WEIGHT: bold; COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">@param</span></span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff"> allows true if this node is allowed to have children */ </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">public</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"></span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">void</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> setAllowsChildren(</span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">boolean</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> allows) { </span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> (allows != </span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; BACKGROUND-COLOR: #ffffff">allowsChildren)</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> { </span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; BACKGROUND-COLOR: #ffffff">allowsChildren </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">= allows; </span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> (!</span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; BACKGROUND-COLOR: #ffffff">allowsChildren)</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> { removeAllChildren(); } } }</span></pre><pre style="BORDER-RIGHT: #000000 0.01mm solid; PADDING-RIGHT: 4px; BORDER-TOP: #000000 0.01mm solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #000000 0.01mm solid; LINE-HEIGHT: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #000000 0.01mm solid; FONT-FAMILY: monospace; BACKGROUND-COLOR: #ffffff"><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> node.removeAllChildren(); DefaultTreeModel model = (DefaultTreeModel) </span><span style="FONT-WEIGHT: bold; COLOR: #660e7a; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">cardTreeView.</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">getModel(); </span><span style="COLOR: #808080; FONT-STYLE: italic; BACKGROUND-COLOR: #ffffff">/* * To avoid having JTree re-expand the root node, we disable * ask-allows-children when we notify JTree about the new node * structure. */ </span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff"> model.setAsksAllowsChildren(</span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">false</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">); model.nodeStructureChanged(node); model.setAsksAllowsChildren(</span><span style="FONT-WEIGHT: bold; COLOR: #000080; BACKGROUND-COLOR: #ffffff">true</span><span style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">);</span></pre><!--EndFragment--><!--EndFragment--><img src ="http://www.aygfsteel.com/Pragmatic/aggbug/58691.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Pragmatic/" target="_blank">鑲栭箯</a> 2006-07-18 09:57 <a href="http://www.aygfsteel.com/Pragmatic/archive/2006/07/18/java_tips_2.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Java tips(1): Vector to Arrayhttp://www.aygfsteel.com/Pragmatic/archive/2006/07/17/java_tips_1.html鑲栭箯鑲栭箯Mon, 17 Jul 2006 09:07:00 GMThttp://www.aygfsteel.com/Pragmatic/archive/2006/07/17/java_tips_1.htmlhttp://www.aygfsteel.com/Pragmatic/comments/58611.htmlhttp://www.aygfsteel.com/Pragmatic/archive/2006/07/17/java_tips_1.html#Feedback0http://www.aygfsteel.com/Pragmatic/comments/commentRss/58611.htmlhttp://www.aygfsteel.com/Pragmatic/services/trackbacks/58611.html 1.
聽聽聽聽聽聽聽vectorObj.trimToSize();聽聽聽//(optional) insure you won't have empty elements
聽聽聽聽聽聽聽ArrayObj[]聽objs = new ArrayObj[vectorObj.size()];
聽聽聽聽聽聽聽vectorObj.toArray(objs);
聽聽聽聽聽聽聽return objs.
2.
聽聽聽聽聽聽 Object[] tempObjectArray = vectorObj.toArray();
聽聽聽聽聽聽 ArrayObj[] objs = new ArrayObj[ tempObjectArray.size() ];
聽聽聽聽聽聽 System.arraycopy (tempObjectArray, 0, objs, 0, objs.size() );
聽聽聽聽聽聽聽return objs;



鑲栭箯 2006-07-17 17:07 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 伊春市| 公主岭市| 中江县| 泾阳县| 南召县| 枞阳县| 哈巴河县| 桐庐县| 龙里县| 松溪县| 天门市| 古蔺县| 全州县| 西畴县| 长沙市| 定南县| 灌南县| 普洱| 汉中市| 霍城县| 焦作市| 孝昌县| 连城县| 南和县| 日喀则市| 汕尾市| 集安市| 荔波县| 岳西县| 华阴市| 连南| 驻马店市| 文化| 沛县| 张家界市| 广元市| 高台县| 格尔木市| 仪征市| 南京市| 湘潭市|