Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JScrollPane

 
bravo9
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I am using GridBagLayout as my layout manager. I have added a JTextArea named display and have then added the GridBagLayout to the ContentPane container. Now I would like to add a JScrollpane to the JTextArea and the code I am using for that is :
////////////////////////////////////////
container.add(new JScrollPane(display);
////////////////////////////////////////
but the JScrollPane is not coming up. What am I doing wrong? Please advise??
 
anu mani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The addition needs to happen in the reverse way. That is the JTextArea should be added to the JScrollPane.
Hope this helps.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not see the TextArea or are you not seeing the Scroll Bars of the ScrollPane? If the latter is true, by default, they will only appear if needed. You can change that by setting the ScrollBarPolicy to Always On.

------------------
Happy Coding,
Gregg Bolinger
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic