• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scrollable JPanel using MigLayout

 
Akheel Firoz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying to create a chat client which makes use of a scrollable jpanel and at runtime adds JTextFields to the panel.

Panel Initialising


Adding text at runtime

But now Im facing the following issues
The text field aligns to the center of the panel & on adding more fields the panel accomodates as it can and does not begin scrolling.

Please help. thanks in advance
Screenshots attatched
2.jpg
[Thumbnail for 2.jpg]
Screenshot
3.jpg
[Thumbnail for 3.jpg]
I have entered messages up to u, but only visible till n
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JScrollPane uses its view component's preferred size to determine whether or not it needs to display scroll bars. Since you've set the preferred size to a specific value, that fixed value is used, and not the preferred size as determined by the layout manager. That means that even though the contents become larger, the preferred size remains the same and so still no scroll bars are needed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!