aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Halp. JTextArea sizing or something Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Halp. JTextArea sizing or something" Watch "Halp. JTextArea sizing or something" New topic
Author

Halp. JTextArea sizing or something

John Yo
Greenhorn

Joined: Dec 01, 2012
Posts: 4
All I want my program to do is to display a text area in a frame with a string.

I have it doing that, but the text is like, way on the bottom of the screen for some reason, so I have to drag the bottom of the window down to even see the text.

I'd be fine with settling for just making the text start from the top. Ideally I'd have the text in an actual text box with a little padding, but this GUI stuff is giving me a huge headache.

I have: and then a little later to change what's in there.

Changing the layout or the rows/columns of the text area does nothing.

I definitely just like, need to add some more code to fix it, but I've been trying to figure out what for the last like two hours and idkwtf to do. I know this code is bush league as hell, sorry.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the textArea needs to be in like a scrollPane and it also needs
to have like a preferredSize larger than the scrollPane's.

ihthyutp
John Yo
Greenhorn

Joined: Dec 01, 2012
Posts: 4
Michael Dunn wrote:the textArea needs to be in like a scrollPane and it also needs
to have like a preferredSize larger than the scrollPane's.

ihthyutp

I tried adding
to test it out and that also did nothing.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the numbers look close enough - the scrollPane will get all of the available space
due to being in a BorderLayout container at the default center position, so that would
be roughly 500,500 (frame size) less space for borders and titlebar.

did you change
frame.add(textbox);
to
frame.add(bs);

to get the textArea to start at the top, add the indicated line
textbox.setText(game.BoardString());
textbox.setCaretPosition(0);//<----------------
John Yo
Greenhorn

Joined: Dec 01, 2012
Posts: 4
Michael Dunn wrote:the numbers look close enough - the scrollPane will get all of the available space
due to being in a BorderLayout container at the default center position, so that would
be roughly 500,500 (frame size) less space for borders and titlebar.

did you change
frame.add(textbox);
to
frame.add(bs);

to get the textArea to start at the top, add the indicated line
textbox.setText(game.BoardString());
textbox.setCaretPosition(0);//<----------------


That also didn't do anything :p
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
post what you have now - remove anything unrelated to the frame/scrollpane/textArea stuff

change
textbox.setText(game.BoardString());
to
textbox.setText("mary had a little lamb...etc); //just enough hard-coded text to duplicate your problem
John Yo
Greenhorn

Joined: Dec 01, 2012
Posts: 4
Well, never mind then.

It was indeed the BoardString. I tried it with "zzz" and it worked fine.

Though that's pretty baffling. But that I can figure out. Probably. Sorry :p

No wonder I couldn't find much info about it.
 
Don't get me started about those stupid light bulbs.
 
subject: Halp. JTextArea sizing or something
 
Similar Threads
General JTextPane help
NullPointerException help....
How do I get layered items to show outside the parent frame?
JFrame in a JFrame?
Getting JTextArea to resize within a JScrollPane