Skip to main content

JTextArea & JScrollPane problems

No replies
g00fy_m
Offline
Joined: 2006-02-17
Points: 0

hi to all,

i have 3 classes communicating (among others) to create a gui and pass info to the textarea in my scrollpane, its the first time ive used scrollpanes but according to the tutorial - it seems to be wired up right, however i cant get any text to display. the text area appears inside the scroller ok but i cant update it.

 => tester.java</p>
<p>InfoScroller info;</p>
<p>this.getContentPane().add(info.getInfoScroller(), new XYConstraints(18, 55, 150, 153));</p>
<p>

 => parser.java</p>
<p>tester test = new tester();</p>
<p>test.info.setInfoText(" line: " + i + " .. " + expression);</p>
<p>

 => InfoScroller.java --> holds the scrollpane and the textarea</p>
<p>infoText = new JTextArea();</p>
<p>// text area inside the scroller<br />
infoText.setWrapStyleWord(true);<br />
infoText.setLineWrap(true);<br />
infoText.setText("");<br />
infoText.setEditable(false);<br />
infoText.setDisabledTextColor(Color.black);<br />
infoText.setToolTipText("Graph Information");<br />
infoText.setDoubleBuffered(false);</p>
<p>// create the scroller for the text area<br />
infoScroller = new JScrollPane(infoText);<br />
infoScroller.setBorder(BorderFactory.createEtchedBorder());<br />
infoScroller.setViewportBorder(BorderFactory.createEtchedBorder());<br />
infoScroller.setVerticalScrollBarPolicy(JScrollPane.<br />
VERTICAL_SCROLLBAR_ALWAYS);<br />
infoScroller.setHorizontalScrollBarPolicy(JScrollPane.<br />
HORIZONTAL_SCROLLBAR_NEVER);<br />
infoScroller.setWheelScrollingEnabled(true);</p>
<p>}</p>
<p>public JScrollPane getInfoScroller() {</p>
<p>return this.infoScroller;</p>
<p>}</p>
<p>public void setInfoText(String text) {</p>
<p>this.infoText.append(text);</p>
<p>}<br />

regards,

g00fy

Admin fixed the code tags