Forums Register Login

Displaying text area

+Pie Number of slices to send: Send
Hi all, I have a little GUI with 5 buttons down the left and a text area on the right, it does not display the text area unless i instantiate it with some text, and even then, its only 1 line big. How can i get it to show when i run my app on the entire right hand side of my GUI?
Also, how do I set the size of my GUI, I want it to start in a position centered in my screen and at least double the sixe it is at the moment.
My code is attached.
Many thanks
Ian
+Pie Number of slices to send: Send
You could add the JTextArea to the center of your BorderLayout directly and not to a panel first. There should be some center logic in this forum somewhere. Try a search and let us know if you find it.
We really need a forum FAQ.
+Pie Number of slices to send: Send
Hi Ian,
For the textarea, u can set the size using setPreferredSize.. u that u need not have to instantiate textarea with some text...
If you are using BorderLayout, put the entire app in the center..
If you want you GUI to appear in the center of th e window, then use the following code :
JDialog d = new JDialog();
Dimension size = d.getToolkit().getScreenSize();
setLocation((size.width - 750) / 2, (size.height - 500) / 2);
Hope this helps you,
Deepa Raghuraman
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1164 times.
Similar Threads
How can I get the GridLayout to work in this program
Swing Program with Buttons
Building a GUI
double to text
Problem with the JButton.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:57:55.