Home arrow static arrow Java Programming [Archive] - Output TextArea
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Output TextArea
This topic has 4 replies on 1 page.

Posts:10
Registered: 3/24/04
Output TextArea  
Jul 3, 2004 4:25 AM



 
Hi, i have a small problem with the JTextArea.

I have a running program and want a log-window tho show what is the program doing currently.

So i created a JFrame class, containing a JTextField.
But how can i set the size of the TextField to a specified value (e.g. 200x200) so that the logging Text beginns on top?

When i set the size of the JTextfield i only have as much Rows as i have Textrows.
 

Posts:24,517
Registered: 98-02-27
Re: Output TextArea  
Jul 3, 2004 8:23 AM (reply 1 of 4)



 
If I understand the question, which is a big if, then this [url http://forum.java.sun.com/thread.jsp?forum=31&thread=413160]thread[/url] should help.
 

Posts:117
Registered: 5/5/98
Re: Output TextArea  
Jul 3, 2004 9:10 AM (reply 2 of 4)



 
Hello,

My approach to setting the size of a component is to subclass the component and provide a getPrefferedSize method.. like this:

contentPane = new JPanel (){   public Dimension getPreferredSize ()   {      return new Dimension(200, 200);   } // end getPreferredSize method}; // end JPanel subclass 


HTH!

Rob
:)
 

Posts:147
Registered: 26.01.04
Re: Output TextArea  
Jul 3, 2004 9:57 AM (reply 3 of 4)



 
hav u tried the setPreferredSize(Dimension) method?
the value u set, will be returned in getPreferredSize(), which your are overriding...

there is also set/getMaximumSize() and set/getMinimumSize()...

if you are using null as the layout of the container your component is in, you can even use the setSize and setLocation(or setBounds for both) to get the proper position and size of your component.
 

Posts:117
Registered: 5/5/98
Re: Output TextArea  
Jul 3, 2004 10:00 PM (reply 4 of 4)



 
I have found that setPreferredSize(Dimension) often gets ignored by the layout manager..
 
This topic has 4 replies on 1 page.