/*
PolyTestViewIAC.java
*/

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

//#1

public final class PolyTestViewIAC extends JFrame
implements StandardColors{

//Class attributes for GUI

JTextArea frameTextArea;

Container frameContainer;

//---------------------------------------PolyTestView------------------------

// Default constructor

public PolyTestViewIAC() {

super("Using an Inner Anonymous Class ");

//Call the primary method of the application
init();
}
//----------------------------------------init-------------------------------

public void init(){

//JFrame method to close the window

//Define GUI components

frameContainer = getContentPane();

frameTextArea = new JTextArea("\tDieselElectric Objects.", 100, 10);

frameTextArea.setEditable(true);

frameTextArea.setLineWrap(true);

frameContainer.add(frameContainer);

//Set window size and make the window visible

setSize(520, 300);

setVisible(true);

//call the testing method

runGeneralTest();
}
//-----------------------------------------runGeneralTest-----------------------
public void runGeneralTest(){

DieselElectric deObjectB = new DieselElectric("DE0001");

DieselElectric deObjectR = new DieselElectric("DE0002");

deObjectB.setExtColor(StandardColors.BLU);

deObjectR.setExtColor(StandardColors.RED);

frameTextArea.append("\n\n A. Interface colors \n");

frameTextArea.append(" StandardColors.BLU :\t "
+ StandardColors.BLU + "\t "
+ deObjectB.getExtColor() );

frameTextArea.append("\n B. \n");
frameTextArea.append(" StandardColors.RED :\t"
+ StandardColors.RED + "\t"
+ deObjectR.getExtColor() );
}
//--------------------------------------main-------------------------------------
public static void main(String args[])

{

//#2 Create an instance of the class

PolyTestViewIAC ptView = new PolyTestViewIAC();

//#3 Use class instance to call the window listener

ptView.addWindowListener(

new WindowAdapter(){

public void windowClosing(WindowEvent e){

System.exit(0);

}//end windowClosing method definition

}//end WindowAdapter class definition

); //end of call to addWindowListener

}//end main

}//end class

This is the complete error I received while working in DOS Command Prompt
"Getting the following error:
“Exception in thread ”main” java.lang.IllegalArgumentException: adding container’s parent to itself
At java.awt.container.checkAddToSelf<Unknown Source>
At java.awt.container.addImpl<Unknown>
At java.awt.container.add<Unknown Source>
At PolyTestViewIAC.init<PolyTestViewIAC.java:49>
At PolyTestViewIAC.<init><PolyTestViewIAC.java:31>
At PolyTestViewIAC.main<PolyTestViewIAC.java:90>"