<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns="http://purl.org/rss/1.0/">
  <channel rdf:about="http://www.planetnetbeans.org/zh_tw/">
    <title>NetBeans 星球</title>
    <link>http://www.planetnetbeans.org/zh_tw/</link>
    <description>NetBeans 星球 - http://www.planetnetbeans.org/zh_tw/</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://fox.jenming.info/?p=50" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=48" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=47" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=44" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=43" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=42" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=41" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=39" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=38" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=37" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=35" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=33" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=31" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=30" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=26" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=24" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=22" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=21" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=19" />
        <rdf:li rdf:resource="http://fox.jenming.info/?p=18" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="http://fox.jenming.info/?p=50">
    <title>NetBeans Rich Client Application (RCP): SaveAction part 2</title>
    <link>http://fox.jenming.info/?p=50</link>
    <content:encoded>&lt;p&gt;說真的，SaveAction 的問題經常困題著筆者。最近，筆者因為要離職了，想說要多利用一下時間把 NetBeans 的東西學一學。所以，筆者就照著 NetBeans RCP 的書中第十章的範例練習。只不過，筆者是執行在 NetBeans 6.0，而非書中的 NetBeans 5.5.1。當然，在筆者心中存著一個想法： NetBeans 6.0 跟 NetBeans 5.5.1 一定有什麼地方不一樣。&lt;/p&gt; &lt;p&gt;經過一些時間之後，筆者發現了一個現象，照書中的範例，居然沒辦法讓 SaveAction 啟用。這…對筆者來說，可以說是其恥大辱啊。我怎麼可能會沒辦法讓它啟用，我都寫過了一篇文章來討論如何啟用 SaveAction。&lt;/p&gt; &lt;p&gt;後來，筆者發現，原來是筆者忘了把 Node 加入 Lookup 之中。&lt;/p&gt; &lt;p&gt;當筆者解決完這個問題後，筆者就想起之前寫的那篇文章中的專案『EnableSaveAction』是用 NetBeans 5.5.1 。如果我們把它移到
    NetBeans 6 之後，是不是 SaveAction 就會改變了。&lt;/p&gt; &lt;p&gt;結果，答案果然是 NetBeans 6 把這個問題給修正了。&lt;/p&gt; &lt;p&gt;大家可以在這邊下載 NetBeans 6 的版本：&lt;a href="http://fox.jenming.info/wp-content/uploads/2008/01/enablesaveaction.zip"&gt;下載&lt;/a&gt; &lt;/p&gt;</content:encoded>
    <dc:date>2008-01-18T16:16:27+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=48">
    <title>NetBeans Rich Client Application (RCP): CallbackSystemAction and Lookup</title>
    <link>http://fox.jenming.info/?p=48</link>
    <content:encoded>&lt;p&gt;這一兩天，有一個中國的朋友寫信來問我一個問題，他/她說：為什麼 CallbackSystemAction 跟 Lookup 一起合著使用時， action map 即使設定了，也無法被 enable。當然，我馬上想到的是，他應該沒有設定對，所以會造成無法被 enable。後來，我看一看我之前的 source code 才發現下面的事實：&lt;/p&gt; &lt;p&gt;當我們在 TopComponent 了設定了 Lookup(即使用 associateLookup 方法)後，必須要把 action map 加到 Lookup 之中（在之前的例子中，我們大多使用 InstanceContent 物件來當 Lookup 的 provider）。大家可以參考下面的網址得到答案：&lt;/p&gt; &lt;p&gt;&lt;a
    href="http://openide.netbeans.org/proposals/actions/impl.html"&gt;http://openide.netbeans.org/proposals/actions/impl.html&lt;/a&gt; &lt;/p&gt;</content:encoded>
    <dc:date>2007-12-29T13:40:49+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=47">
    <title>NetBeans Rich Client Application (RCP): Spider.Net</title>
    <link>http://fox.jenming.info/?p=47</link>
    <content:encoded>&lt;p&gt;What do I do recently??? Spider.Net is the answer. I have opened an open source project, that is Spider.Net, recently. Spider.Net is a framework for web crawler. It provides many building blocks for web crawler construction. With these building blocks, you can build a web crawler easily. In Spider.Net, there are three main project: 1. Spider Framework, 2. Spider Runtime, 3. Runtime Environment. Spider Framework provides building blocks. Spider Runtime is driven by an XML
    configuration file. With XML configuration file, Spider Runtime can builds and runs a web crawler which is built dynamically. Runtime Environment is a kind of sample application which wraps Spider Runtime.&lt;br /&gt; The url is: &lt;a href="http://code.google.com/p/spiderframework/"&gt;http://code.google.com/p/spiderframework/&lt;/a&gt;. Hope this project is useful to you. &lt;/p&gt;</content:encoded>
    <dc:date>2007-09-04T13:44:54+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=44">
    <title>NetBeans Rich Client Application (RCP): 啟用 SaveAction 及 SaveAllAction</title>
    <link>http://fox.jenming.info/?p=44</link>
    <content:encoded>&lt;p&gt;之前，筆者在開發 NetBeans RCP 的過程中，發生了一個非常怪異的問題。在 NetBeans Platform 的文件中指出，SaveAction 只要在 Lookup 中放入一個 Node 及一個 SaveCookie 就能夠啟用。但是，筆者不管怎麼試，都試不出來。最後，筆者也忘了是做了什麼事才讓它 enable ，可能是把某個 Netbeans 的 Module 加入之後吧。&lt;/p&gt; &lt;p&gt;最近，筆者又被 assign 了另一個專案，也是要用 NetBeans Platform 來設計。好死不死，筆者又遇到了一模一樣的問題（SaveAction 無法被 enable）。這次，筆者就決定把它給記錄下來。&lt;/p&gt; &lt;p&gt;這篇文章算是一篇記錄性質的文章，我們將討論一下，如何讓 SaveAction（呈現出來是在 File/Save 的選單中）被啟用。同時，我們也會討論一下，如何使用最少的程式來啟用 SaveAction 及 SaveAllAction。這些問題都是在
    dev@openide.netbeans.org 討論串中常出現的文章。如果，大家曾經看過，或已經知道 work around ，就可以略過啦。&lt;/p&gt; &lt;p&gt;&lt;a id="more-44"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1. 問題描述&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;NetBeans 的 SaveAction 可以說是一個奇怪的玩意。 NetBeans 的文件中指出，SaveAction 要被啟用的條件是 Lookup 中有只有一個 Node ，且這個 Node 的 Lookup 有一個 SaveCookie 在裡面，筆者還去看過 SaveAction 的 source code 也是這樣設計的。但是，不論我們如何設計，都還是無法研 SaveAction 被啟用。根據 &lt;a
    href="http://openide.netbeans.org/servlets/ReadMsg?listName=dev&amp;amp;msgNo=19141"&gt;http://openide.netbeans.org/servlets/ReadMsg?listName=dev&amp;amp;msgNo=19141&lt;/a&gt; 這篇文章的討論，同樣的問題不止出現在 SaveAction ，還出現在 PrintAction 。本文也將根據上述文章的內容為主，來設計一個測試這個問題及其 work around 的專案。&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2. 建立測試用的專案&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;我們要建立一個名叫 EnableSaveAction 的 module suite 及一個名叫 EnableSave 的 module 專案，並將 EnableSaveAction 專案設定成 Standalone Application。&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3.
    建立 TopComponent&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;我們接著要建立一個名叫 SaveAction 的 TopComponent，並在它的設計畫面中放入兩個 JButton 及一個 JTextArea ，如下圖。其中，JButton 分別用來啟用 Save 及停用 Save ；JTextArea 是用來顯示一些訊息。&lt;br /&gt; &lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction3.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4. 測試問題&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;首先，我們要建立一個沒用的 Node 及一個會顯示儲存訊號的 SaveCookie ，程式碼如下：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-7"&gt;&lt;a
    href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-7"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000;
    font-weight: bold;"&gt;private&lt;/span&gt; SaveCookie m_SaveCookie;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; Node m_DummyNode;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div
    style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; SaveCookie getSaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #b1b100;"&gt;if&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;m_SaveCookie==&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_SaveCookie=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; SaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt;
    &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; save&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #000000;
    font-weight: bold;"&gt;throws&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;IOException&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;jTextArea1.&lt;span style="color:
    #006600;"&gt;setText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;jTextArea1.&lt;span style="color: #006600;"&gt;getText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; + &lt;span style="color: #ff0000;"&gt;"I am saved.&lt;span style="color: #000099; font-weight: bold;"&gt;\r&lt;/span&gt;&lt;span style="color: #000099; font-weight: bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyDO.&lt;span style="color: #006600;"&gt;setModified&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span
    style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; m_SaveCookie;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family:
    'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; Node getNode&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #b1b100;"&gt;if&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;m_DummyNode==&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyNode=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; AbstractNode&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;Children.&lt;span style="color: #006600;"&gt;LEAF&lt;/span&gt;, m_Lookup&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyNode.&lt;span style="color: #006600;"&gt;setName&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Dummy Node"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold;
    color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyNode.&lt;span style="color: #006600;"&gt;setShortDescription&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Useless node"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color:
    #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; m_DummyNode;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black;
    font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;接著就是依照我們常用的方式來建立一個 InstanceContent 及 Lookup 如下：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-8"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN
    TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-8"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; Lookup
    m_Lookup;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; InstanceContent m_InstanceContent;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier,
    monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; SaveActionTopComponent&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;initComponents&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;setName&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color: #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;SaveActionTopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"CTL_SaveActionTopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;setToolTipText&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color: #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;SaveActionTopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"HINT_SaveActionTopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier,
    monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;//&#160; &#160; &#160; &#160; setIcon(Utilities.loadImage(ICON_PATH, true));&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;m_InstanceContent=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; InstanceContent&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_Lookup=&lt;span style="color:
    #000000; font-weight: bold;"&gt;new&lt;/span&gt; AbstractLookup&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;m_InstanceContent&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;associateLookup&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;m_Lookup&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color: #006600;"&gt;add&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getNode&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;這段程式碼是在 SaveActionTopComponent 的 constructor
    中設計的，所以在程式開始執行的時候，就會將我們所建立出來的 Dummy Node 加入 Lookup 中。&lt;/p&gt; &lt;p&gt;接下來，我們在 Enable Save（jButton1）及 Disable Save（jButton2）的兩個 JButton 中加入以下的程式碼：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-9"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-9"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New',
    Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; jButton2ActionPerformed&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color: #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color: #006600;"&gt;event&lt;/span&gt;.&lt;a
    href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color:
    #006600;"&gt;remove&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getSaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;jTextArea1.&lt;span style="color: #006600;"&gt;setText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;jTextArea1.&lt;span style="color: #006600;"&gt;getText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; + &lt;span style="color: #ff0000;"&gt;"remove save cookie.&lt;span style="color: #000099; font-weight: bold;"&gt;\r&lt;/span&gt;&lt;span style="color: #000099; font-weight:
    bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier
    New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; jButton1ActionPerformed&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color: #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color:
    #006600;"&gt;event&lt;/span&gt;.&lt;a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div
    style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color: #006600;"&gt;add&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getSaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace;
    font-weight: normal;"&gt;jTextArea1.&lt;span style="color: #006600;"&gt;setText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;jTextArea1.&lt;span style="color: #006600;"&gt;getText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; + &lt;span style="color: #ff0000;"&gt;"put save cookie.&lt;span style="color: #000099; font-weight: bold;"&gt;\r&lt;/span&gt;&lt;span style="color: #000099; font-weight:
    bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt;
    &lt;p&gt;在這段程式碼中，我們分別將 SaveCookie 加入到 InstanceContent 或從 InstanceContent 移除。&lt;/p&gt; &lt;p&gt;程式執行後，我們可以按下 Enable Save 的按鈕，將會發現 File/Save 並沒有被啟用，畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction1.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;5. 加入 SaveAction 的 work around&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;根據 &lt;a
    href="http://openide.netbeans.org/servlets/ReadMsg?listName=dev&amp;amp;msgNo=19141"&gt;http://openide.netbeans.org/servlets/ReadMsg?listName=dev&amp;amp;msgNo=19141&lt;/a&gt; 的討論，我們可以發現，只須要將 SaveAction 加到 Tool Bar 之中，就可以解決 SaveAction 的問題。所以，我們打開 layer.xml 檔，並加入以下的 XML ：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="lxml-10"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span
    class="langName"&gt;XML:&lt;/span&gt; &lt;div id="xml-10"&gt; &lt;div class="xml"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;folder&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span
    style="color: #ff0000;"&gt;"Toolbars"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;folder&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span
    style="color: #ff0000;"&gt;"File"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color:
    black;"&gt;&amp;lt;file&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"SaveAction.shadow"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color:
    #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;attr&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"originalFile"&lt;/span&gt; &lt;span style="color: #000066;"&gt;stringvalue&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"Actions/System/org-openide-actions-SaveAction.instance"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;/file&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;attr&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"com-xmlgem-xmleditor-action-OpenNewAction.shadow/org-openide-actions-SaveAllAction.instance"&lt;/span&gt; &lt;span
    style="color: #000066;"&gt;boolvalue&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"true"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color:
    #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;/folder&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;/folder&lt;span style="font-weight: bold; color:
    black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;加入之後，我們再次執行，並按下 Enable Save 的按鈕，發現 SaveAction 被正常地啟用。同時按下它，也能有對應的反應。畫面如下：&lt;br /&gt; &lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction4.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;6. 加入 SaveAllAction 的 work around&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;SaveAllAction 的行為向來都是很正常的，所以這裡，我們將討論有沒有較簡單的方式可以啟用它。&lt;/p&gt;
    &lt;p&gt;這裡，我們將在記憶體中建立一個 Dummy.txt 的 FileObject ，並利用這個 FileObject 來得到系統預設的 DataObject 。透過這個 DataObject ，我們就可以利用 setModified 來讓 SaveAllAction 啟用了。&lt;/p&gt; &lt;p&gt;在設計之前，我們必須將 Datasystems API 及 File System API 給引用進來，完成後的畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction7.jpg" /&gt;&lt;/p&gt; &lt;p&gt;我們要在 SaveActionTopComponent 的 constructor 加入以下的程式碼，並多宣告一個 DataObject 的變數：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-11"&gt;&lt;a
    href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-11"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000;
    font-weight: bold;"&gt;private&lt;/span&gt; DataObject m_DummyDO;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; Lookup m_Lookup;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div
    style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; InstanceContent m_InstanceContent;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; SaveActionTopComponent&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;initComponents&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt;
    &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;setName&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color: #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;SaveActionTopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color:
    #ff0000;"&gt;"CTL_SaveActionTopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;setToolTipText&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color:
    #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;SaveActionTopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"HINT_SaveActionTopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace;
    font-weight: normal;"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;//&#160; &#160; &#160; &#160; setIcon(Utilities.loadImage(ICON_PATH, true));&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent=&lt;span style="color: #000000; font-weight:
    bold;"&gt;new&lt;/span&gt; InstanceContent&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_Lookup=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; AbstractLookup&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;m_InstanceContent&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;associateLookup&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;m_Lookup&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color: #006600;"&gt;add&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getNode&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;//for enable SaveAll&lt;/span&gt;&lt;/div&gt; &lt;/li&gt;
    &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;FileObject oDummyFileObj=&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span
    style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;oDummyFileObj = FileUtil.&lt;span style="color: #006600;"&gt;createMemoryFileSystem&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getRoot&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;createData&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Dummy.txt"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight:
    bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;IOException&lt;/span&gt;&lt;/a&gt; ex&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;ex.&lt;span style="color: #006600;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span
    style="color: #b1b100;"&gt;if&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;oDummyFileObj==&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight:
    bold;"&gt;throw&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3ARuntimeException+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;RuntimeException&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Error, DummyFileObj hasnt been create"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt;
    &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight:
    bold;"&gt;try&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;m_DummyDO=DataObject.&lt;span style="color: #006600;"&gt;find&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;oDummyFileObj&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;DataObjectNotFoundException ex&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;ex.&lt;span style="color: #006600;"&gt;printStackTrace&lt;/span&gt;&lt;span
    style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family:
    'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;接下來，我們修改一下 SaveCookie 及 Enable/Disable Save 的事件處理程式：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-12"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span
    class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-12"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; jButton2ActionPerformed&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color: #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color: #006600;"&gt;event&lt;/span&gt;.&lt;a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color:
    #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color: #006600;"&gt;remove&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getSaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight:
    normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyDO.&lt;span style="color: #006600;"&gt;setModified&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New',
    Courier, monospace; font-weight: normal;"&gt;jTextArea1.&lt;span style="color: #006600;"&gt;setText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;jTextArea1.&lt;span style="color: #006600;"&gt;getText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; + &lt;span style="color: #ff0000;"&gt;"remove save cookie.&lt;span style="color: #000099; font-weight: bold;"&gt;\r&lt;/span&gt;&lt;span style="color: #000099; font-weight:
    bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier
    New', Courier, monospace; font-weight: normal;"&gt;&#160;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; jButton1ActionPerformed&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color: #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color: #006600;"&gt;event&lt;/span&gt;.&lt;a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color:
    #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_InstanceContent.&lt;span style="color: #006600;"&gt;add&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;getSaveCookie&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal;
    font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;m_DummyDO.&lt;span style="color: #006600;"&gt;setModified&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier,
    monospace; font-weight: normal;"&gt;jTextArea1.&lt;span style="color: #006600;"&gt;setText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;jTextArea1.&lt;span style="color: #006600;"&gt;getText&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; + &lt;span style="color: #ff0000;"&gt;"put save cookie.&lt;span style="color: #000099; font-weight: bold;"&gt;\r&lt;/span&gt;&lt;span style="color: #000099; font-weight:
    bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt;
    &lt;p&gt;完成之後，可以再執行一次，並按下 Enable Save 的按鈕，我們將可以發現 Save 及 Save All 都被啟用了：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction5.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt; 7. 討論&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;在這裡，我們可以使用這兩個 work around 來啟用 SaveAction 及 SaveAllAction 。但是，當我們按下 Enable Save 後，我們如果將程式關閉，NetBeans 則會顯示有個名叫 Dummy.txt 的檔案尚未被儲存，如下圖：&lt;br /&gt; &lt;img src="http://fox.jenming.info/pic/EnableSaveAction/EnableSaveAction6.jpg" /&gt;&lt;/p&gt;
    &lt;p&gt;此時，Dummy.txt 就是我們之前在記憶體中建立的空白檔案，這邊，如果大家有須要的話，可以針對不同的情況建立不同名稱的檔案。&lt;/p&gt; &lt;p&gt;另外，如果我們按下 Save 或 Save All ，我們的 SaveCookie 將不會被呼叫到。這是因為，NetBeans 會透過 DataObject 來取得 SaveCookie ，然而，我們的 SaveCookie 是存在 InstanceContent 之中，並沒有存在 DataObject 中，所以不會被呼叫到。針對這個問題，我們可以使用 DataObject 的 Modified Property Change 事件來處理。&lt;/p&gt; &lt;p&gt;最後，筆者必須提一下，關於 SaveAction 的部份，筆者相信在不久的將來 Netbeans 的開發團隊會修正它，所以，大家如果採用這種方式，記得在程式碼中加個註記。關於 SaveAllAction 的部份，這裡所介紹的方法是在最少程式碼的方式來完成它，所以，有許多小細節會無法設定，例如 DataObject 的 icon
    …等。&lt;/p&gt; &lt;p&gt;完整的程式碼可以在這裡&lt;a href="http://fox.jenming.info/wp-content/uploads/2007/06/enablesaveaction.zip"&gt;下載&lt;/a&gt;。 &lt;/p&gt;</content:encoded>
    <dc:date>2007-06-22T08:30:36+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=43">
    <title>NetBeans Rich Client Application (RCP): 詭異的系統標題（Application Title）</title>
    <link>http://fox.jenming.info/?p=43</link>
    <content:encoded>&lt;p&gt;大家在開發許多 NetBeans RCP 之後一定會發現，每次建立一個 Module Suite 專案後，NetBeans 幫我們自動帶出的 Application Title 中，都有著一段奇怪的數字（例如： MyProgressBar 200704122300，見下圖）。這個問題其實也困擾著筆者很久，所以，筆者決定花時間去研究一下如何在設計階段就將系統的標頭更改成我希望的格式。所以，這篇文章將會和大家討論一下，筆者發現可以用來修改 Application Title 的方式。這篇文章將著重在，以修改設定檔的方式來完成這項工作。當然，在先前討論的 &lt;a href="http://fox.jenming.info/?p=30"&gt;Login Dialog&lt;/a&gt; 中，我們曾經使用過 ModuleInstall ，讓 NetBeans RCP 能在 Window Opened 事件發生時顯示一個 Login Dialog ，同樣的方式也用來可以動態地修改標頭。&lt;/p&gt; &lt;p&gt;&lt;img
    src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;a id="more-43"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1. 選擇要修改的專案&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;這篇文章，我們將使用上一篇所建立出來的 MyProgressBar 的專案當成是實行範例。大家可以在這裡下載到&lt;a href="http://fox.jenming.info/wp-content/uploads/2007/06/myprogressbar.zip"&gt;專案的原始碼&lt;/a&gt;。&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2. 修改設定檔&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;NetBeans 在顯示標題的時候，其實是從具備 branding 的 libraries 中讀出設定檔，這部份其實是和我們之前介紹的
    multi-lingual 文章有關，建議大家先閱讀過&lt;a href="http://fox.jenming.info/?p=8"&gt;這篇文章&lt;/a&gt;，再來看接下來的部份，將會比較了解 NetBeans 的運作。&lt;/p&gt; &lt;p&gt;我們要修改的設定檔是否 branding 有關的設定檔，所以我們將無法在 Projects 的 tab 中找到。我們必須要把它切換到 Files 的 tab 中才能找到。切換到 Files 的 tab 後，我們可以看到許多目錄，我們可以將 MyProgressBar/branding/modules 打開。在裡面，有兩個目錄，一個是 org-netbeans-core-windows.jar 、另一個是 org-netbeans-core.jar ，這兩個 modules 將會是影響系統載入時標題的樣子。我們接下來把這兩個 module 的目錄全部打開，將可以看到以下的畫面：&lt;/p&gt; &lt;p&gt;&lt;img
    src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy4.jpg" /&gt;&lt;/p&gt; &lt;p&gt;其實，我們要改的部份，只有 org-netbeans-core-windows.jar 裡面的 Bundle.properties 檔。將檔案打開後畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy5.jpg" /&gt;&lt;/p&gt; &lt;p&gt;我們只須要修改 CTL_MainWindow_Title 及 CTL_MainWindow_Title_No_Project 這兩個參數，就可以改變系統標題了。在這裡，我們把 {0} 的部份給刪除。完成後，再執行一次系統，我們將可以得到以下的畫面：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy6.jpg"
    /&gt;&lt;/p&gt; &lt;p&gt;那個奇怪的標題就不見了。&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3. 修改 About 視窗的資訊&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;About 視窗中的資訊也可以用類似的方式來加以修改，例如以下是原始的樣子：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy7.jpg" /&gt;&lt;/p&gt; &lt;p&gt;畫紅線的部份將是我們會修改到的地方。&lt;/p&gt; &lt;p&gt;接下來，我們將剛剛 modules 的另一個模組（org-netbeans-core.jar）給打開，並且將它裡面包含的 Bundle.properties 給打開。打開後畫面會類似下圖：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy9.jpg"
    /&gt;&lt;/p&gt; &lt;p&gt;我們只須要改變 LBL_ProductInformation 就可以修改 About 視窗中的 Product 的名稱。在這裡，我們將它改成 MyProgressBar ~~。&lt;/p&gt; &lt;p&gt;接下來，我們要在 Files 的 tab 中將 branding/core 給打開，會發現裡面有個名叫 core.jar 的目錄，它會是 NetBeans 在啟動的時候最接近核心的部份。我們可以把它目錄結構打開（如下圖），並將其中的 Bundle.properties 也打開：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy2.jpg" /&gt; &lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy3.jpg" /&gt;&lt;br /&gt; 在這個檔案中，我們可以修改 currentVersion 的屬性，就可以修改到 About 視窗中的
    Product Version 的字。在這裡，我們將它改成 MyProgressBar Pre-Release {0} 的字樣，並再執行一次。我們可以得到下面的視窗：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/tips/ulgy%20title/ulgy8.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4. 結語&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;筆者首經在 NetBeans 的官網或 Google 中搜尋如何修改標題的方法，但是都無所獲。所以，筆者才會進行這篇文章所描述的測試。說真的，這個方法可能不是比較好的方法，但是，還算得上是一個簡單的方法。如果，大家在學習 NetBeans 上知道其它的修改標題的方法，還煩請教導一下我們吧。 &lt;/p&gt;</content:encoded>
    <dc:date>2007-06-15T03:37:19+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=42">
    <title>NetBeans Rich Client Application (RCP): Getting Started 系列 - Progress API 補充</title>
    <link>http://fox.jenming.info/?p=42</link>
    <content:encoded>&lt;p&gt;這篇文章算是關於 Progress API 的小小註記。&lt;/p&gt; &lt;p&gt;幾天前，我寫了一篇關於 Progress API 的文章，當然，我也很高興地使用著 NetBeans 的 Progerss API 來建立我希望的介面。但是，在我進行程式設計的過程中，卻發生了一些些的小插曲：&lt;br /&gt; &lt;a id="more-42"&gt;&lt;/a&gt;&lt;br /&gt; 1. &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in
    org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#start%28%29"&gt;start&lt;/a&gt;&lt;/strong&gt;()&lt;/code&gt; 與 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandleFactory.html" target="classFrame" title="class in
    org.netbeans.api.progress"&gt;ProgressHandleFactory&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandleFactory.html#createProgressComponent%28org.netbeans.api.progress.ProgressHandle%29"&gt;createProgressComponent&lt;/a&gt;&lt;/strong&gt;(&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" title="class
    in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt; handle)&lt;/code&gt; 的使用&lt;/p&gt; &lt;p&gt;如果，我們須要使用 ProgressHandleFactory.createProgressComponent 來建立一個使用者介面的話，它必須要在 ProgressHandle.start 被呼叫之前進行，否則會出現 exception 。&lt;/p&gt; &lt;p&gt;老實說，個註記是理所當然的，所有的初始化，都必須在 start 之前完成。但是，很多時候，我們都還是會乎略掉這個小細節。&lt;/p&gt; &lt;p&gt;2. &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html"
    target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandle.&lt;/a&gt;&lt;/font&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;&lt;code&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/code&gt;&lt;/a&gt;&lt;strong&gt;&lt;a
    href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#start%28%29"&gt;start&lt;/a&gt;&lt;/strong&gt;() 、&lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a
    href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#start%28int%29"&gt;start&lt;/a&gt;&lt;/strong&gt;(int workunits)&lt;/code&gt;&lt;font class="FrameItemFont"&gt; &lt;/font&gt; 與 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in
    org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#start%28int,%20long%29"&gt;start&lt;/a&gt;&lt;/strong&gt;(int workunits, long estimate)&lt;/code&gt; 的使用&lt;/p&gt; &lt;p&gt;到底什麼時候，我們要使用 start() 而不使用 start(int) 或 start(int, long)。基本上，筆者認為，這部份也是大家容易搞錯的地方，在 Progress API 的 javadoc 中有明確地提到：start() 是用在處理一個不確定工作項目（indeterminate
    mode）時使用； start(int) 則是用在知道有幾個工作項目（determinate mode）的時候使用；start(int, long) 除了指定有幾個工作項目外，還多指定了一個預計完成時間。所以，我們在使用時，必須要明確地使用正確的方法。&lt;/p&gt; &lt;p&gt;當然，乍看之下，大家可能會覺得只是一個 start 而己沒什麼。 但是，根據 Progress API 的設計，一個 ProgressHandle 在 start 的時候，如果是屬於不確定工作項目的情況下，接下來所使用的 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in
    org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt;&lt;/font&gt;.&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28java.lang.String%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;&lt;/code&gt; 也要是不確定工作項目的方法。ProgressHandle 的 progress 有三種不同的 override 形式：1. &lt;code&gt;&lt;strong&gt;&lt;a
    href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28int%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(int workunit)&lt;/code&gt;、2. &lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28java.lang.String%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(&lt;a
    href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in java.lang"&gt;String&lt;/a&gt; message)&lt;/code&gt;、3. &lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28java.lang.String,%20int%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(&lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in
    java.lang"&gt;String&lt;/a&gt; message, int workunit)&lt;/code&gt;。這三種形式中，第二個項目（ &lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28java.lang.String%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(&lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in java.lang"&gt;String&lt;/a&gt;
    message)&lt;/code&gt;）是不確定工作項目專用的方法；第一、三項（&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28int%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(int workunit)&lt;/code&gt; 及 &lt;code&gt;&lt;strong&gt;&lt;a
    href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28java.lang.String,%20int%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;(&lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html" title="class or interface in java.lang"&gt;String&lt;/a&gt; message, int workunit)&lt;/code&gt;）目則是用在已經工作項目的方法。如果這個地方用錯了，也將會有 exception 出現哦。 &lt;/p&gt;</content:encoded>
    <dc:date>2007-06-13T07:01:03+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=41">
    <title>NetBeans Rich Client Application (RCP): Getting Started 系列 - Progress API</title>
    <link>http://fox.jenming.info/?p=41</link>
    <content:encoded>&lt;p&gt;Progress 是 NetBeans 中用來呈現目前執行狀態的一個 API ，大家可能會覺得，我們己經有了 JProgressBar ，幹嘛還要這種東西。其實， &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/allclasses-frame.html" target="packageFrame"&gt;Progress API&lt;/a&gt;&lt;/font&gt; 提供了一些簡易的方法讓我們可以很容易地在 NetBeans 中呈現一個 Progress Bar 。&lt;br /&gt; 大家在開啟 NetBeans 的時候，可以發現 NetBeans 在右下角（ Status Bar 的右方）中有一個顯示 Scanning Project Classpaths 的 Progress Bar，它代表著 NetBeans 正在執行 Scanning
    專案的 Classpath 的進度。 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/allclasses-frame.html" target="packageFrame"&gt;Progress API&lt;/a&gt;&lt;/font&gt; 即可做到這項功能。我們將在這篇文章討論一下， Progress API 較簡單的使用方法，致於 Aggregate 的部份將留到之後的文章再做介紹。在這次的範例中，我們將建立一個 Thread 用來測試 Progress Bar ，所以我們讓它執行 100 次的迴圈，每次執行時，透過呼叫 Thread.sleep (300) 的方式，讓它暫停 300 ms ，直到執行完成。&lt;/p&gt; &lt;p&gt;&lt;a id="more-41"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1.
    備準專案&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;在每次的一開始，我們都必須準備一個 NetBeans Module Suite 的專案，用來呈現這次的結果。這次，我們建立一個名叫 MyProgressBar 的 Module Suite 專案，及一個名叫 ProgressBar 的 Module 專案。如果大家忘了如何建立專案，可以參考&lt;a href="http://fox.jenming.info/?p=15"&gt;之前的文章&lt;/a&gt;。建立完成後畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress1.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2. 設計 TopComponent&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;我們可以使用 NetBeans 的 Wizard 來建立一個 TopComponent（即 Window
    Component）。首先，我們先建立一個名叫 HeavyJob 的 TopComponent ，完成後，如下圖所示：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress2.jpg" /&gt;&lt;/p&gt; &lt;p&gt;接下來，我們在畫面上加入一個 JButton ，讓它顯示成『Execute Heavy Job』，並叫它 m_Execute 。完成後如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress3.jpg" /&gt;&lt;/p&gt; &lt;p&gt;在我們進行程式設計之前，我們要將 Progress API 的模組引用進來，我們可以在 ProgressBar 專案上按右鍵，選擇 Project Properties 的項目。接下來，我們要在 Categories 為 Libraries 的項目中加入 Progress API &amp;amp;
    UI 的模組，加入完成後如下圖所示：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress4.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3. 程式設計-&lt;/strong&gt;&lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt; &lt;/font&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br /&gt; 我們在 m_Execute 的 JButton 的
    actionPerformed 事件中加入以下的程式碼：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-16"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-16"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div
    style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; m_ExecuteActionPerformed&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color: #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color: #006600;"&gt;event&lt;/span&gt;.&lt;a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span
    style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160;
    &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;final&lt;/span&gt; ProgressHandle oHandle=ProgressHandleFactory.&lt;span style="color: #006600;"&gt;createHandle&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Heavy Job Progress Bar"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal;
    font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt; oHeavyThread=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a
    href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; run&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; oHandle.&lt;span style="color: #006600;"&gt;start&lt;/span&gt;&lt;span
    style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; color: #800000;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color:
    #993333;"&gt;int&lt;/span&gt; i=&lt;span style="color: #cc66cc; color: #800000;"&gt;0&lt;/span&gt;;i&amp;lt;&lt;span style="color: #cc66cc; color: #800000;"&gt;100&lt;/span&gt;;i++&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace;
    font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;a
    href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;sleep&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; color: #800000;"&gt;300&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black;
    font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;a
    href="http://www.google.com/search?q=allinurl%3AInterruptedException+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;InterruptedException&lt;/span&gt;&lt;/a&gt; ex&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160;
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; ex.&lt;span style="color: #006600;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160;
    &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; oHandle.&lt;span style="color: #006600;"&gt;progress&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"前進 #"&lt;/span&gt; + i&lt;span
    style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight:
    bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;out&lt;/span&gt;.&lt;span style="color: #006600;"&gt;println&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"前進 #"&lt;/span&gt; + i&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160;
    &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; oHandle.&lt;span style="color: #006600;"&gt;finish&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span
    style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New',
    Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; oHeavyThread.&lt;span style="color: #006600;"&gt;start&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span
    style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;在這段程式碼中，我們首先使用 &lt;font
    class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandleFactory.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandleFactory&lt;/a&gt; 建立一個名叫『Heavy Job Progress Bar』的 &lt;/font&gt;&lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class
    in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt; 物件。我們可以使用 &lt;/font&gt;&lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt; 來讓 Progress Bar 前進，並顯示一些訊息。接下來，我們建立一個 Thread ，讓它每隔 300 ms 呼叫 &lt;/font&gt;&lt;font class="FrameItemFont"&gt;&lt;a
    href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html" target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandle&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandle.html#progress%28int%29"&gt;progress&lt;/a&gt;&lt;/strong&gt;&lt;/code&gt;&lt;font class="FrameItemFont"&gt;
    一次。在這段程式中，我們&lt;strong&gt;&lt;em&gt;一定&lt;/em&gt;&lt;/strong&gt;要把 heavy job 放在一個新的 Thread 之中，否則，整個系統將不會有任何的反應。這是因為，這段程式碼是在 m_Execute 處理事件的 Tread 中執行，如果我們將 heavy job 放在這個 Thread 中執行，外加這個 Thread 是 Swing Thread （它的優先權為最高），它將會把 UI 的更新動作給卡住。所以，在這邊，我們建立了另一個 Thread ，這個 Thread 的優先權會比 Swing Thread 低，利用這個 Thread 來執行耗時的工作，將可讓 Swing 又更新 UI 又執行工作。&lt;br /&gt; &lt;/font&gt;&lt;/p&gt; &lt;p&gt;執行後，畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress5.jpg" /&gt;&lt;/p&gt;
    &lt;p&gt;上面的訊息是當我們按下 Progress Bar 後顯示才能出來。&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4. 顯示 Progress Bar 的 Dialog&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;很多時候，我們都會須要在顯示一個 modal dialog 用來防止使用者在程式執行的過程中按下其它的指令。所以，我們接下來討論一下如何使用 NetBeans 的 Progress API 來達到這功能。&lt;/p&gt; &lt;p&gt;首先，我們先在 HeavyJobTopComponent 中加入另一個 JButton ，顯示成『Execute Job in Dialog』，並讓它叫 m_ExecuteDialog 。完成後畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress8.jpg" /&gt;&lt;/p&gt; &lt;p&gt;接下來，我們使用 NetBeans 的 wizard
    建立一個名叫 ProgressDialog 的 JDialog ，並在上面放入一個名叫 m_ProgressBarContainer 的 JPanel ，建立完後成畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress6.jpg" /&gt;&lt;/p&gt; &lt;p&gt;我們接著在 ProgressDialog 加入以下的程式碼：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-17"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div
    id="java-17"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight:
    bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt; m_Thread;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span
    style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; init&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;ProgressHandle h, &lt;a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt; r&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; m_ProgressBarContainer.&lt;span style="color: #006600;"&gt;add&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;ProgressHandleFactory.&lt;span style="color: #006600;"&gt;createProgressComponent&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;h&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;, &lt;a
    href="http://www.google.com/search?q=allinurl%3ABorderLayout+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;BorderLayout&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;CENTER&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier,
    monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; m_Thread=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;r&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt;
    &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div
    style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; setVisible&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #993333;"&gt;boolean&lt;/span&gt; b&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier
    New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;b &amp;amp;&amp;amp; m_Thread!=&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; m_Thread.&lt;span style="color: #006600;"&gt;start&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black;
    font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; m_Thread=&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color:
    #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; super.&lt;span style="color: #006600;"&gt;setVisible&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;b&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;我們在 init 的時候，使用 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandleFactory.html"
    target="classFrame" title="class in org.netbeans.api.progress"&gt;ProgressHandleFactory&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/5_5_1/javadoc/org-netbeans-api-progress/org/netbeans/api/progress/ProgressHandleFactory.html#createProgressComponent%28org.netbeans.api.progress.ProgressHandle%29"&gt;createProgressComponent&lt;/a&gt;&lt;/strong&gt;&lt;/code&gt;&lt;font class="FrameItemFont"&gt; 的方法來建立一個 Progress&lt;/font&gt; Bar，並把它放在
    m_ProgressBarContainer 之中。接著，我們建立了一個名叫 m_Thread 的 Thread 會負責執行傳入的 Runnable 物件。接下來，我們在 setVisible 中執行 m_Thread。&lt;/p&gt; &lt;p&gt;完成 ProgressDialog 後，我們可以在 HeavyJobTopComponent 中 m_ExecuteDialog 的 actionPerformed 事件中，加入以下的程式碼：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="ljava-18"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-18"&gt;
    &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; m_ExecuteDialogActionPerformed&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;java.&lt;span style="color:
    #006600;"&gt;awt&lt;/span&gt;.&lt;span style="color: #006600;"&gt;event&lt;/span&gt;.&lt;a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;ActionEvent&lt;/span&gt;&lt;/a&gt; evt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;
    &#160; &#160; &#160; &#160; &#160; &#160; &lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;final&lt;/span&gt; ProgressDialog oDialog=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; ProgressDialog&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;WindowManager.&lt;span style="color:
    #006600;"&gt;getDefault&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getMainWindow&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;, &lt;span style="color: #000000; font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier,
    monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;final&lt;/span&gt; ProgressHandle oHandle=ProgressHandleFactory.&lt;span style="color: #006600;"&gt;createHandle&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Heavy Job Progress
    Bar"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt; oRunnable=&lt;span style="color: #000000; font-weight:
    bold;"&gt;new&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color:
    #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; run&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt;
    &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; oHandle.&lt;span style="color: #006600;"&gt;start&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; color: #800000;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style:
    normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #993333;"&gt;int&lt;/span&gt; i=&lt;span style="color: #cc66cc; color: #800000;"&gt;0&lt;/span&gt;;i&amp;lt;&lt;span style="color: #cc66cc; color: #800000;"&gt;100&lt;/span&gt;;i++&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New',
    Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;.&lt;span style="color:
    #006600;"&gt;sleep&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; color: #800000;"&gt;300&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;span
    style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?q=allinurl%3AInterruptedException+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;InterruptedException&lt;/span&gt;&lt;/a&gt; ex&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier,
    monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; ex.&lt;span style="color: #006600;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt;
    &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160;
    &#160; &#160; &#160; oHandle.&lt;span style="color: #006600;"&gt;progress&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"前進 #"&lt;/span&gt; + i&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;a
    href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;out&lt;/span&gt;.&lt;span style="color: #006600;"&gt;println&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"前進 #"&lt;/span&gt; + i&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New',
    Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160;
    &#160; oHandle.&lt;span style="color: #006600;"&gt;finish&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;a
    href="http://www.google.com/search?q=allinurl%3ASwingUtilities+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;SwingUtilities&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;invokeLater&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd;
    font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #000000; font-weight:
    bold;"&gt;public&lt;/span&gt; &lt;span style="color: #993333;"&gt;void&lt;/span&gt; run&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160;
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; oDialog.&lt;span style="color: #006600;"&gt;setVisible&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160;
    &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier,
    monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; oDialog.&lt;span style="color: #006600;"&gt;init&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;oHandle, oRunnable&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt;
    &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; oDialog.&lt;span style="color: #006600;"&gt;setVisible&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;out&lt;/span&gt;.&lt;span style="color:
    #006600;"&gt;println&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"執行完成..."&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;
    &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;在這段程式碼中，它和之前的程式一樣，但是我們加入了 ProgressDialog 的物件，並將我們所建立起來的 ProgressHandle 及 Runnable 物件交給它。比較特別的地方是，我們在 Runnable 物件執行完成後，使用 SwingUtilities.invokeLater 方法來關閉 ProgressDialog ，這是因為，所有 Swing 的更新都要在 Swing Thread 之中完成。&lt;/p&gt; &lt;p&gt;執行的畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/progressbar/progress7.jpg" /&gt;&lt;/p&gt; &lt;p&gt;完整專案&lt;a
    href="http://fox.jenming.info/wp-content/uploads/2007/06/myprogressbar.zip"&gt;下載 &lt;/a&gt; &lt;/p&gt;</content:encoded>
    <dc:date>2007-06-08T09:47:31+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=39">
    <title>NetBeans Rich Client Application (RCP): 近況</title>
    <link>http://fox.jenming.info/?p=39</link>
    <content:encoded>&lt;p&gt;前陣子，我被我們老闆（或叫老師吧）調去做另一個專案的事情，所以導致整個五月都沒有什麼文章進帳，真的很對不起各位。還好，目前那個專案已經告一段落了，我又被調回設計使用 NetBeans RCP 的專案。所以，最近，應該又能再寫些文章。 &lt;/p&gt;</content:encoded>
    <dc:date>2007-06-08T08:32:04+00:00</dc:date>
  </item>
  <item rdf:about="http://fox.jenming.info/?p=38">
    <title>NetBeans Rich Client Application (RCP): Getting Started 系列 - 讀取及儲存 Preference</title>
    <link>http://fox.jenming.info/?p=38</link>
    <content:encoded>&lt;p&gt;一般的系統大多會使用自己設計的格式來儲存使用者的偏好設定，可是，要設計一套很完整的模型將不是一件容易的事。NetBeans 在這個地方有很不錯的表現，我們可以使用先前介紹的 layer.xml 機制來完成這項工作。這篇文章將討論如何使用 layer.xml 來儲存使用者的偏好設定，以及簡單介紹 FileObject 的應用，共分成三個部份：讀取設定值、透過程式寫入設定值、及透過程式讀取連結到外部檔案的設定。&lt;/p&gt; &lt;p&gt;&lt;a id="more-38"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p style="font-weight: bold;"&gt;1. 建立專案&lt;/p&gt; &lt;p&gt;我們首先要建立 Module Suite 及 Module 的專案，建立的方式可以參考之前的文章。在這篇文章中，我們會建立一個名叫『Save Your Preference Info』的 Module Suite 及『ReadWrite Preference』的
    Module，建立完成後，畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/preference/pref17.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2. 由 layer.xml 中讀取設定值&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;layer.xml 在 NetBeans 中會被轉成一個虛擬的 FileSystem ，所有的 file 及 folder 的 element 都會被轉成 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/FileObject.html" target="classFrame" title="class in
    org.openide.filesystems"&gt;FileObject&lt;/a&gt; &lt;/font&gt;，而 attr 的 element 將會被轉成 FileObject 的 Attribute。所以，我們可以透過 FileSystem 來存取到它。我們可以使用 &lt;font class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/Repository.html" target="classFrame" title="class in org.openide.filesystems"&gt;Repository&lt;/a&gt;.&lt;/font&gt;&lt;code&gt;&lt;strong&gt;&lt;a
    href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/Repository.html#getDefault%28%29"&gt;getDefault&lt;/a&gt;&lt;/strong&gt;()&lt;/code&gt;.&lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/Repository.html#getDefaultFileSystem%28%29"&gt; getDefaultFileSystem&lt;/a&gt;&lt;/strong&gt;()&lt;/code&gt; &lt;font class="FrameItemFont"&gt; &lt;/font&gt; 來取得 layer.xml 的 &lt;font
    class="FrameItemFont"&gt;&lt;a href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/FileSystem.html" target="classFrame" title="class in org.openide.filesystems"&gt;FileSystem&lt;/a&gt; &lt;/font&gt; 物件，這個 FileSystem 物件也將會是 NetBeans 用來儲存系統設定及偏好設定的地方。&lt;/p&gt; &lt;p&gt;在我們這個例子中，我們預計會將 JButton 的 X, Y 位置儲存在 layer.xml 當中，然後在程式執行起來後，將 JButton 定位在指定的位置。所以，首先我們先在 layer.xml 中加入一個名叫『Button.position』的 file element，然後在它底下，宣告兩個 atrribute 分別是 x 和 y，完成後的樣子如下：&lt;/p&gt;
    &lt;div class="igBar"&gt;&lt;span id="lxml-27"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;XML:&lt;/span&gt; &lt;div id="xml-27"&gt; &lt;div class="xml"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace;
    font-weight: normal;"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;file&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"Button.position"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;attr&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"x"&lt;/span&gt; &lt;span style="color: #000066;"&gt;intvalue&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"10"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li
    style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;attr&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"y"&lt;/span&gt; &lt;span style="color:
    #000066;"&gt;intvalue&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"250"&lt;/span&gt;&lt;span style="font-weight: bold; color: black;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #009900;"&gt;&lt;span style="font-weight: bold; color: black;"&gt;&amp;lt;/file&lt;span style="font-weight: bold; color:
    black;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;接下來，我們在我們建立的專案中，新增一個名叫 Type1 的 TopComponent ，並讓它在一開始的時候就顯示在 editor 的位置中，如下圖：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/preference/pref.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/preference/pref2.jpg" /&gt;&lt;/p&gt; &lt;p&gt;建立完成後，我們一樣要將會用到的 Module 給加進來，加入完成後，會如下圖示所：&lt;/p&gt; &lt;p&gt;&lt;img
    src="http://fox.jenming.info/pic/preference/pref3.jpg" /&gt;&lt;/p&gt; &lt;p&gt;接下來就是在我們建立的 Type1TopComponent 中放置一個 JButton，另外，因為我們希望能狀態地指定位置，所以要將 layout manager 給取消掉，讓它成為 null layout ，如下圖：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/preference/pref4.jpg" /&gt;&lt;/p&gt; &lt;p&gt;設定成 null layout：&lt;/p&gt; &lt;p&gt;&lt;img src="http://fox.jenming.info/pic/preference/pref5.jpg" /&gt;&lt;/p&gt; &lt;p&gt;完成後，我們要在 Type1TopComponent 的建構子中加入以下的程式碼：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span
    id="ljava-28"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;JAVA:&lt;/span&gt; &lt;div id="java-28"&gt; &lt;div class="java"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span
    style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; Type1TopComponent&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; initComponents&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span
    style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; setName&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color: #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;Type1TopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"CTL_Type1TopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160;
    setToolTipText&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;NbBundle.&lt;span style="color: #006600;"&gt;getMessage&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;Type1TopComponent.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"HINT_Type1TopComponent"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family:
    'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;//&#160; &#160; &#160; &#160; setIcon(Utilities.loadImage(ICON_PATH, true));&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight:
    normal;"&gt;&#160; &#160; &#160; &#160; FileSystem oFS=&lt;a href="http://www.google.com/search?q=allinurl%3ARepository+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Repository&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006600;"&gt;getDefault&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getDefaultFileSystem&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; FileObject oFile=oFS.&lt;span style="color: #006600;"&gt;findResource&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span
    style="color: #ff0000;"&gt;"Button.position"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;oFile!=&lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #993333;"&gt;int&lt;/span&gt; iX=&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?q=allinurl%3AInteger+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;oFile.&lt;span style="color: #006600;"&gt;getAttribute&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"x"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;intValue&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &#160; &#160; &lt;span style="color: #993333;"&gt;int&lt;/span&gt; iY=&lt;span style="color:
    #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?q=allinurl%3AInteger+java.sun.com&amp;amp;bntl=1"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;oFile.&lt;span style="color: #006600;"&gt;getAttribute&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"y"&lt;/span&gt;&lt;span style="color:
    #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;.&lt;span style="color: #006600;"&gt;intValue&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160;
    &#160; &#160; &#160; jButton1.&lt;span style="color: #006600;"&gt;setLocation&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;iX, iY&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-weight: bold; color: #26536A;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;li style="font-family: 'Courier
    New', Courier, monospace; color: black; font-weight: normal; font-style: normal; color: #3A6A8B;"&gt; &lt;div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"&gt;&#160; &#160; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;這段程式碼是從 Repository 中取得 DefaultFileSystem ，再透過 FileSystem.findResource 將 Button.position 的 FileObject 給讀取出來。 取得 Button.position 後，我們可以使用
    &lt;code&gt;&lt;strong&gt;&lt;a href="http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/FileObject.html#getAttribute%28java.lang.String%29"&gt;getAttribute&lt;/a&gt;&lt;/strong&gt;(&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang"&gt;String&lt;/a&gt; attrName)&lt;/code&gt; 的方法，將我們儲存在 layer.xml 中的 x 與 y 給讀出。&lt;/p&gt; &lt;p&gt;程式執行後的畫面如下：&lt;/p&gt; &lt;p&gt;&lt;img
    src="http://fox.jenming.info/pic/preference/pref6.jpg" /&gt;&lt;/p&gt; &lt;p&gt;接下來，當我們把 x, y 改成 10 及 250 ，執行後的畫面就變成：&lt;br /&gt; &lt;img src="http://fox.jenming.info/pic/preference/pref7.jpg" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3. 從程式寫入偏好設定到 layer.xml&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;在這個例子中，我們預計設計一個文字編輯器（使用 JTextArea 就好），以及一個能夠動態改變字型的功能（使用 JSlider），讓使用者能自行決定希望的字型大小及輸入文字。當使用者輸入完成後了之後，可以按下 Save 的按鈕，將輸入的文字及字型大小儲存起來，下次執行的時候，系統就會自動載入前次設定的字型大小。另外，當使用者按下 Load 的按鈕時，會將之前儲存的文字也載入進來。&lt;br /&gt; 首先，我們先在
    layer.xml 中建立一個 Folder 名叫 Type2 ，在裡面建立一個 File 名叫 FontSize.size，並給它一個名叫 size 的 attribute，完成後如下所示：&lt;/p&gt; &lt;div class="igBar"&gt;&lt;span id="lxml-29"&gt;&lt;a href="http://fox.jenming.info/?feed=rss2&amp;amp;cat=3"&gt;PLAIN TEXT&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="syntax_hilite"&gt;&lt;span class="langName"&gt;XML:&lt;/span&gt; &lt;div id="xml-29"&gt; &lt;div class="xml"&gt; &lt;ol&gt; &lt;li style="font-family: 'Courier New', C