• Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing Scrollbars In JTextPane

 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have programmed a Swing component requiring scrollbars in the usual way by instantiating the JScrollPane and adding a JTextPane to it.
My program allows the user to add files into the JTextPane which are visually represented by an ImageIcon in a JLabel. The JTextPane is programmed with a flow layout. When I test it by adding icons with a drag and drop gesture from the native system, the icons fill the JTextPane one after the other just as they would with a flow layout from left to right, however when the row of icons reaches the bottom of the window, no scrollbars appear and the icons can be added without errors showing up.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difficult to know how to help without more details. What have you got on the contents of the JScrollPane? FlowLayout may make it awkward, because it doesn't constrain the size of Components, so the scroll bars may never appear.
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got a Component call IconCell that has an ImageIcon in the Center Layout, and the text label for the file name in the South Layout. The Icon is the same one that represents the file in Window from whence it came via:



I have used the setPreferredSize() mehod to be the same Dimension regardless of the length of the filename and to accomodate the natural size of the big icon obtained using the above method.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still don't know. Where are you adding the JScrollPane?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recent thread, see if there's any similarity

http://www.coderanch.com/t/457512/Swing-AWT-SWT-JFace/java/hopefully-simple-textbox
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!