Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.IllegalArgumentException: adding a window to a container

807603Apr 4 2005 — edited Feb 7 2008
Hello all,

I have a problem with this bit of code:
	/**
	* Private method for setting up the table.
	*/
	private void setupTable()
	{
		setLayout(new BorderLayout()); //added

		//sets up the playing table
		//creates the playing surface
		myTable = new TheTable(thePlayers); 
		//sets size
		myTable.setSize(1024, 768);		
		//add listener
		myTable.addWindowListener(this);
		//adds title to frame
		myTable.setTitle("Portland v0.02b, (C)2004 Clements Software");
		//shows the table
		myTable.show();													

		add(myTable, "Center"); //added to layout
	}
The compiler returns:
Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
        at java.awt.Container.addImpl(Container.java:616)
        at java.awt.Container.add(Container.java:518)
        at TheDealer.setupTable(TheDealer.java:130)
        at TheDealer.<init>(TheDealer.java:33)
        at Portland.main(Portland.java:5)
Now I have had this running before about a year ago and have just come back to it on a new machine.

I will be thankfull for any help,
Harold Clements
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2008
Added on Apr 4 2005
10 comments
2,517 views