File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes TextArea components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TextArea components" Watch "TextArea components" New topic

TextArea components

Ian Cockcroft

Joined: Feb 17, 2002
Posts: 29
Hi All,
I am trying to get a GUI with 2 TextArea's, one above the other. It compiles fine, but I am getting this error when i run it:
java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(
at javax.swing.JLayeredPane.addImpl
at java.awt.Container.add(
at javax.swing.JRootPane.setContentPane
at javax.swing.JFrame.setContentPane
at StreamGUI.main(

The Code

Any Ideas?
Jeff Smith
Ranch Hand

Joined: May 04, 2001
Posts: 50
It's the line where you say:
frame.setContentPane( new StreamGUI() );
Your StreamGUI class is a frame itself, so you should use it as a one. You don't need to call setContentPane() because the content's were already set in it's constructor. As for the error, it's because you're trying to add a JFrame to a JFrame, you can only add a Container as the contents of a JFrame.
[ April 14, 2002: Message edited by: Jeff Smith ]
I agree. Here's the link:
subject: TextArea components
It's not a secret anymore!