JScrollPane in an applet

J

Jeff Sandler

Do components work differently (or not at all) just because they're in
an applet vs. an application? My applet has a JTextArea inside a
JScrollPane and it doesn't seem to show the scroll bar no matter what.

I've tried setting the scroll bar policy, resizing the applet within the
HTML, resizing the JScrollPane, resizing the JTextArea, resizing browser
window while it's showing the applet, etc. The scroll bar still didn't
show. I even tried making it an application instead of an applet, and
the scroll bar was there just like I expected. Here's a portion of the
init() method in question....

outputArea = new JTextArea();
StringBuffer deleteMe = new StringBuffer();

for(int i=1;i<=100;i++)
{
deleteMe.append(i);
deleteMe.append("\n");
}
outputArea.setText(deleteMe.toString());
scroller = new JScrollPane(outputArea);
Container myContainer = getContentPane();
myContainer.setLayout(new FlowLayout());
myContainer.add(scroller);

scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

Also, I don't know if this is significant or not. When I highlight the
text in the JTextArea, it acts like the text ends where the bottom of
the JTextArea ends. In other words, the rest of the text just
disappears. Thank you in advance for your help.
 
A

Andrew Thompson

Jeff said:
Do components work differently (or not at all) just because they're in
an applet vs. an application? My applet has a JTextArea inside a
JScrollPane and it doesn't seem to show the scroll bar no matter what.
Often the problem is the width and height
you specify in the applet call, instead of specifying, eg.

width=200
height=200

try..

width="99%"
height=2400

(or some other ridiculously large number)
to see what I mean.
...I even tried making it an application instead of
an applet, and the scroll bar was there just like I expected. Here's
a portion of the init() method in question....


With applets, the _complete_ source,
the _applet_ _tag_, and best of all,
a _URL_ would be helpful!
http://www.physci.org/codes/sscce.jsp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top