Java Reference
In-Depth Information
Google's technology news RSS at http://news.google.com/
news?pz=1&cf=all&ned=us&hl=en&topic=tc&output=rss .
Figure 17-11 depicts the orange RSS icon in the upper left.
Figure 17-11 . The RSS icon
Once the URL is accepted via drag-and-drop or via the text field, the JavaFX RSS
reader application will save the URL location to a database. The RSS application con-
sists of three frame regions: the RSS feed title column (left), headline news (upper
right), and the website view (lower right). To display the news headlines, click the hy-
perlinks to the left. To show the entire article in the lower-right frame, click the View
button below the headline in the upper-right frame. Before running the code, the ap-
plication will require the JAR libraries derby.jar and derbytools.jar to be in-
cluded in your project class path. These libraries allow you to save RSS URLs to an
embedded JDBC database.
Similar to what you did in Recipe 17-3, you retrieve news information from the In-
ternet. The RSS retrieved will be using version 2.0. RSS is an XML standard that
provides really simple syndication, thus the acronym. Now enough with the acronyms;
let's jump into the code, shall we?
In the start() method, you create a 640 by 480 white scene display area. Next,
you create a map ( TreeMap ) containing Hyperlink objects as values and keys rep-
resenting the URL location ( String ) to the RSS feed. As before when displaying
HTML content, you need to create WebView s. Here you create two WebView s and
one WebEngine . The two WebView s will render HTML for the news headline frame
region and the viewing of the entire article region (lower right). The single We-
bEngine is responsible for retrieving the RSS feed when the user clicks the left frame
region containing the RSS hyperlinks.
To support the feature that allows the user to enter an RSS feed, you need to create
a text field that can save and render the headline news. The following code snippet
saves an RSS URL and adds an address as a new hyperlink to the list of feeds.
 
 
Search WWH ::




Custom Search