hi,
I'm writing a simple app, i want the JTextArea size to change when the
frame size changes, i used ComponentListener and the componentResized
for the frame, the problem is i don't know which methods will change
the size of the JTextArea i tried resize(e.getComponent().getSize());
but it didn't work!.
thanks in advance
regards,
Andrew Thompson - 25 May 2005 09:42 GMT
> ..i want the JTextArea size to change when the
> frame size changes
Use a layout manager, that is what they are for.
<sscce>
import java.awt.*;
import javax.swing.*;
class ResizableTextArea {
public static void main(String[] args) {
JFrame f = new JFrame( "Resizable TextArea" );
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Container c = f.getContentPane();
c.setLayout( new BorderLayout() );
c.add( new JScrollPane(
new JTextArea("Text Area", 5,20) ),
BorderLayout.CENTER );
c.add( new JButton("UP"), BorderLayout.NORTH );
c.add( new JTextField("DOWN"), BorderLayout.SOUTH );
c.add( new JLabel("L"), BorderLayout.WEST );
c.add( new JLabel("R"), BorderLayout.EAST );
f.pack();
f.setVisible(true);
}
}
</sscce>
For GUI tutorials you might start here..
<http://java.sun.com/docs/books/tutorial/uiswing/index.html>
For GUI related questions, see here..
<http://www.physci.org/codes/javafaq.jsp#cljg>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Thomas Weidenfeller - 25 May 2005 15:47 GMT
> I'm writing a simple app, i want the JTextArea size to change when the
> frame size changes, i used ComponentListener and the componentResized
> for the frame, the problem is i don't know which methods will change
> the size of the JTextArea i tried resize(e.getComponent().getSize());
> but it didn't work!.
Use layout managers instead.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq