set JTextPane to max possible size
I'm writing an application using swing and I want to stretch out the JTextPane to take whole possible space.
For now, there is nothing in there except the JTextPane, but it takes only the space it needs, when due to aesthetics I want it to take whole possible space. Preferably I would like to do it with layouts, instead of using fixed size. Currently I use BorderLayout.

18 Replies
⌛ This post has been reserved for your question.
Hey @dezodorant! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
anyone?
I don't see you using BorderLayout here. So if you add this it should work.
Thats how I use border layout:
Sorry for so late reply, I didnt notice the message
Ok, so here is a minimal working example for your case:
The problem here is that the
JScrollPane is only a clipped viewer on the underlying FileView. The latter one is not attached to any parent component of which it could inherit any sizes.so I have to attach it to something for it to inherit a size?
I am not sure, haven't worked with Swing that much lately but I think the scrolling could already be attached to some text component without wrapping it in a ScrollPane.
wdym?
When I unwrap the fileView from JScrollPane, then the issue is the same, it's just not scrollable

Ah, you need to set the Layout of the
FileView. Currently it uses FlowLayout.

it works! Thanks a lot
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
For the future, how can I know that some layout allows it when other doesnt?
Usually you need to make sure that your used LayoutManager matches the given layout contraints. Since this a kind of old API it uses
Object arguments everywhere and does not enforce anything in the type system.
A more modern API would probably have warned you or even failed to build because the BorderLayout.CENTER is not supported by FlowLayout.okay thanks'
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@949384053809901579>.