Forums Register Login

add(lable) doesnt show till i resize

+Pie Number of slices to send: Send
im trying to move my debugging output from system.out.println() to the frame i made with the awt that already has some buttons and things in it. so every time i do something, im trying to do this.add(label) to tell me that what i expect is being done is being done. but when i add lables, they dont show up until i resize the window, and then it shows up horizontally to the left and vertically centered. so i figure, the other stuff in the window is hiding it, so i try setSize(200,200) in the constructor. But that didnt even resize the window! now, i have to resize the window to 400 pixels vertically to see the text show up, as if all it did was make a big white block of size 200x200 that hides my new lables! whats the right way to move my debugging to this frame?
+Pie Number of slices to send: Send
Welcome to Java Ranch!

The first thing to realize is that any time you change the structure of a graphical element (like adding components to a frame/panel), you need to call validate() on it to tell it that it needs to re-do it's layout and display work.

Next, what you are describing is a very heavy-weight way to view debugging messages. It might be easier to create a scrolling text area, then just add your messages to the text displayed by that text area.

+Pie Number of slices to send: Send
thanks i will look up how to do that
+Pie Number of slices to send: Send
got it working! thank you very much
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1104 times.
Similar Threads
Oversized JPanel
JToolBar Buttons to Wrap to second line as needed
New button to JFrame
GridBagLayout squishes components on resize
html frame resize only vertically not horizontally
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:05:07.