File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Real Quick, whats wrong with my JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Real Quick, whats wrong with my JScrollPane" Watch "Real Quick, whats wrong with my JScrollPane" New topic

Real Quick, whats wrong with my JScrollPane

matt gimbl

Joined: Feb 15, 2004
Posts: 5
Okay ... In my main GUI file .. I have declared this ...
tab.add(new EditArea("TextAreaName"), "TabName"); // Not showing my TextArea
tab.add(new JScrollPane(new TextArea("TextAreaName")), "TabName"); // Does show my text area
where tab is a JTabbedPane, TextArea is a class that extends JEditorPane, and Edit Area is a class that extends JScrollPane.
This is the code for my EditArea():
public class EditArea extends JScrollPane {
public EditArea(String nameOfTextArea) {
add(new TextArea(nameOfTextArea));
I dont see any logical differences in the code .. but the first tab shows just a big container with nothing in it, but the second tab shows the correct JEditorPane window. What am I doing wrong?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

JScrollPane is one of the only components that the normal "add()" method doesn't do what you think it should. The method that you have to use instead is "setViewPortView()".

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Real Quick, whats wrong with my JScrollPane
Similar Threads
How to use getModel() with JTabbedPane ?
Issues with JTextArea as cellEditor of JTable Column.
Correct usage of InvokeLater ?
retrieving values from JTabbedPane
Problem with scroll