<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>冰糖葫芦 &#187; JTextArea</title>
	<atom:link href="http://www.icycandy.com/blog/tag/jtextarea/feed" rel="self" type="application/rss+xml" />
	<link>http://www.icycandy.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 07 Sep 2010 15:54:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>在JavaFX中实现TextArea</title>
		<link>http://www.icycandy.com/blog/implementing-textarea-in-javafx</link>
		<comments>http://www.icycandy.com/blog/implementing-textarea-in-javafx#comments</comments>
		<pubDate>Sat, 05 Dec 2009 14:52:31 +0000</pubDate>
		<dc:creator>icycandy</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JTextArea]]></category>

		<guid isPermaLink="false">http://www.icycandy.com/?p=10880</guid>
		<description><![CDATA[<p>最初发布的JavaFX技术预览版里是有TextArea的，大概需要导入类似于javafx.ui.*;[......]</p><p class='read-more'><a href='http://www.icycandy.com/blog/implementing-textarea-in-javafx'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>最初发布的JavaFX技术预览版里是有TextArea的，大概需要导入类似于javafx.ui.*;这样的包。可是当JavaFX进化到1.0正式版的时候，不知为何已经没有了这样基础的控件=.=<br />
用Swing里的JTextArea可以实现这样的功能。效果如图。<br />
<img src="http://www.icycandy.com/wp-content/uploads/2009/12/javafx-textarea.jpg" /></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * TextArea.fx
 *
 * Created on 2009-12-5, 22:27:47
 */</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Scene</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Dimension</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JScrollPane</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JTextPane</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.ext.swing.SwingComponent</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author icycandy
 */</span>
&nbsp;
var text<span style="color: #339933;">:</span> <span style="color: #003399;">JTextPane</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JTextPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
var pane<span style="color: #339933;">:</span> <span style="color: #003399;">JScrollPane</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JScrollPane</span><span style="color: #009900;">&#40;</span>text,<span style="color: #003399;">JScrollPane</span>.<span style="color: #006633;">VERTICAL_SCROLLBAR_ALWAYS</span> ,<span style="color: #003399;">JScrollPane</span>.<span style="color: #006633;">HORIZONTAL_SCROLLBAR_NEVER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lovelovelove&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
text.<span style="color: #006633;">setPreferredSize</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Dimension</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Application title&quot;</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            SwingComponent.<span style="color: #006633;">wrap</span><span style="color: #009900;">&#40;</span>pane<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.icycandy.com/blog/implementing-textarea-in-javafx/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
