This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

TextArea components  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!