??xml version="1.0" encoding="utf-8" standalone="yes"?>国产视频欧美视频,久久在线精品视频,亚洲一区亚洲二区http://www.aygfsteel.com/Pragmatic/best practiceszh-cnWed, 18 Jun 2025 19:09:11 GMTWed, 18 Jun 2025 19:09:11 GMT60Mail list _N-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.

l合使用JUnit和Cobertura可能是不错的选择?/p>

肖鹏 2006-09-16 09:59 发表评论
]]>
设计模式漫谈Q?Q:Factory Method可以用static实现吗?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〔本站副站发布,ȝQdesignpatterns.cnblogs.com?/p>

○。背景与背景知识

q是昨天在QQ上D的一个例子。本文ƈ不是从头讲Factory Method模式Q仅对其实现l节q行讨论。关于这个模式可以参?a target="_blank">wayfarer?a target="_blank">吕震?/a>的文章?/p>

一。分?/p>

因ؓFactory MethodQ大写的Factory Method表示模式名称Q模式的一个目的就是得创为(factory methodQ(写的factory method表示创徏行ؓҎ(gu)Q抽象化Q由子类实现Q从而容易扩展。一个纯的Factory Method模式Q其factory method是不能用static来实现的。通常Simple Factory模式才会由static来实现?/p>

但是Q一个Factory拥有一个static的创建方法是很诱人的。用户在M时候只要用cdQFactory的类名)既可以创建出需要的Product?a target="_blank">wayfarer 的文章最后给出的DotNet的实现部分就是这L例子。吕震宇的另一?a >文章 Q关于Simple Factory模式Q的回复?a >Walkdanl出的解x案也是这L。从本质上,q两个例子都不是U的Factory Method模式或者Simple Factory模式Q而是Simple Factory模式和Factory Method模式的组合应用?/p>

引用Walkdan的回复:

Simple Factory最大的好处是把变化集中C一处。另外,LightSimpleFactory.Create()里面的依赖关pM可以消除Q我的做法是:

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。这? 通过注册构造子Q?.中原来的switch()q程被消除,依赖关系随之解除。其中的Register(), Find()Ҏ(gu)理解Q方法就不写了?/em>

新的cd可通过新注册构造子来实现扩展。当?中的注册代码仅仅是示例,完全可以攑ֈ配置文g中去实现Q比如:

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

其ILightCreatorl承体系Q是Factory Method模式。LightSimpleFactory和creators的关pWalkdan没有说明Q也可实CؓStrategy模式?/p>

二。引申问?/p>

  1. 模式中factory method一定要是抽象的吗? NO.你可以定义一个默认的Ҏ(gu)Q生产某UProduct。这样即使Factory没有子类也可以生产这U默认品。通常q种情况下Factory是一个接口,然后定义一个BasicFactory来生产BasicProduct。其他的Factory由BasicFactoryz。注意,往往Factory和Product是^行的l承l构?
  2. Factory Method解耦了client和concreteProductQ是不是又引入了client和concreteFactory的耦合Q?q个问题很好Q答案是可能Q《head first design patterns》一书中的例子就有这个问题)Q但是client端不应该依赖concreteFactory。如果依赖concreteFactoryQ那真是画蛇添了(?a target="_blank">wayfarer的文章)?
  3. Factory Method模式的好处有哪些Q?
    1. 装了对象的创徏。对象的创徏如果使用new来完成,则与实现c(concreteProductQ是紧耦合的。Factory Method的创为factory methodQ返回Product接口Q从而解耦了client和concreteProduct?
    2. 易于扩展。相对于Simple Factory模式QFactory Method模式可以通过zq行扩展?/li>

三。结?/p>

一个纯的Factory Method模式其factory method不可以用static实现Q通过与其他模式结合用可以进行变通。而且通常情况下Factory Method模式都会与其他模式相l合。Abstract Factory模式通常是用Factory 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.M心得交流Q大家可以相U一赯书互怺?br />2.技术交,M与设计模式相养I包括重构Q测试驱动,敏捷开发等Q开发中遇到的问题?br />要求臛_发表q一关于设计模式的文章才可以加入?br />http://group.qq.com/group_index.shtml?funcid=1&groupid=26227899
友情提示Q如果你只打“听”,不打“说”或者“问”,对你的帮助会的多?br />

肖鹏 2006-09-02 22:05 发表评论
]]>
Effective Java 阅读W记Q-W一章,引言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.清晰性和介性是最为重要的Q一个模块的用户永远也不应该被模块的行ؓ所qhQ那样就不清CQ;模块要尽可能的小Q但又不能太〔术语模块(moduleQ在本书中的用法Q是指Q何可重用的Y件组Ӟ从单个方法,到包含多个包的复杂系l都可以是一个模块〕?/p>

2.代码应该被重用,而不是被拯?/p>

3.模块之间的相依性应该尽可能降低到最?/p>

4.错误应该早被检出来,理想情况下是在编译时刅R?/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 Ҏ(gu)件名是区分大写?/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 Ҏ(gu)件名是区分大写?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看上d父节?/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 />通常一个TreeNode QDefaultMutableTreeNodeQ如果没有子l点Q它的节Ҏ(gu)CZؓ不可展开的节点,有时候我们希望即使该节点暂时没有装蝲子结点仍然显CZؓ可展开的节点(如图<img height="10" alt="ParentNode.jpg" src="http://www.aygfsteel.com/images/blogjava_net/pragmatic/JTips/ParentNode.jpg" width="15" border="0" />Q。比如,当加载子l点比较耗时或者需要动态刷斎ͼ可以延时加蝲子结点,卛_展开节点的时候再去装载子l点?br />1.由来及解x?br />该属性取决于QDefaultTreeModel的isLeafҎ(gu)</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-->而asksAllowsChildren由方法setAsksAllowsChildren讑֮<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">注意Q在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和true。这是因为nodeStructureChanged会自动的试图展开节点nodeQ如果isLeafq回为false。试惻IasksAllowsChildrenq回trueQ则一个结点即使没有子l点Q只要设|了allowsChildrenQ对应的treeNodeModel的isLeaf׃q回true。然而当自动展开节点的时候发现ƈ没有子结点,当然׃把图?img height="10" alt="ParentNode.jpg" src="http://www.aygfsteel.com/images/blogjava_net/pragmatic/JTips/ParentNode.jpg" width="15" border="0" />L了。而先把asksAllowsChildren设ؓfalseQ就不会去试囑ֱ开该节点,然后设ؓtrueQ该节点׃昄?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 发表评论
]]>
վ֩ģ壺 | | ˮ| ̶| | ɽ| ľ| | ֦| | Զ| ʡ| | ɫ| ɳ| ڰ| | | ʡ| ۽| | | | | | | | ˮ| | | | ɽ| ո| ˳| ӥ̶| | ¤| ˮ| | ˮ| ʳ|