• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Real Quick, whats wrong with my JScrollPane

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay ... In my main GUI file .. I have declared this ...
tab.add(new EditArea("TextAreaName"), "TabName"); // Not showing my TextArea
and
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()".
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!