• Post Reply Bookmark Topic Watch Topic
  • New Topic

JScrollBar in JPanel  RSS feed

 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have following code:

It compiles fine but when i run it, the html document does not fit the JEditorPane area however I don't see any scollbars. So i could not view the whole document.
I need your urgent help, thanks in advance.
Cheers
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as you are working inside the jvm you don't have to worry about the direction of the
slashes. The 'getResource' method takes some of the strain out of making up URLs. Its use is
explained on the page "How to Use Icons" in the Swing tutorial.

The trouble was with the layout. The default size of JPanel is (10, 10) and Flowlayout is
the default layout manager. When you load the inhaltScroll into the inhaltPanel, the
inhaltPanel will assume the preferred size of the inhaltScroll. When you add the inhaltPanel
to the parent Container, here the enclosing class StudyTest (a JPanel by extension), with
its default FlowLayout inhaltPanel will be shown at its preferred size. However, FlowLayout
lays everything out in a line which will cause the inhaltPanel to collapse to its minimum
size of (10, 10) or go offscreen. If you set the layout for the inhaltPanel and the parent
JPanel to BorderLayout the components will be expanded to fill all the available space.
You could also eliminate inhaltPane and load the inhaltScroll into the Center section of
the parent class BorderLayout.
This works okay and displays the scroll bars when loaded.
 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works fine and that is what i need. Thank you very much for your help and great explanations Craig.
Cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!