This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying text area  RSS feed

 
Ian Cockcroft
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepa Raghuraman
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!