This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes TextArea components Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "TextArea components" Watch "TextArea components" New topic
Author

TextArea components

Ian Cockcroft
Greenhorn

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(Container.java:336)
at javax.swing.JLayeredPane.addImpl
(JLayeredPane.java:201)
at java.awt.Container.add(Container.java:267)
at javax.swing.JRootPane.setContentPane
(JRootPane.java:358)
at javax.swing.JFrame.setContentPane
(JFrame.java:550)
at StreamGUI.main(StreamGUI.java:52)

The Code

Any Ideas?
Thanks
Ian
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.
Jeff
[ April 14, 2002: Message edited by: Jeff Smith ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: TextArea components
 
Similar Threads
JInternal Frame and ActionListener
Using JPanel to create JTabbedPane
Why aren't my components wrapping?
last week of class last assignment. Any help is appreciated.
Wordwrap on a JTextArea