fatjoy25 0 Newbie Poster
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.event.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class MyPaint extends JApplet implements 

Runnable  
{
/* Declaring the variables.*/
JPanel panel;
JPanel textAreaPanel;
JTextArea drawTextArea;
JScrollPane drawScrollPane;
JLabel line, color, paint,kid,cil;
JButton circle, rect, poly, ellipse;
JComboBox cbLine, cbFill;
GridBagLayout g;
GridBagConstraints gbc;
Thread datimeThread;
Date date;
GregorianCalendar calendar;
String strDate, strTime, strStatus;
public void init()
{
g=new GridBagLayout();  
gbc=new GridBagConstraints();
panel= (JPanel)getContentPane();
panel.setLayout(g);
paint = new JLabel("My Paint Application");
gbc.anchor= GridBagConstraints.NORTH;
gbc.gridx =2;
gbc.gridy = 0;
g.setConstraints(paint,gbc);
panel.add(paint);
rect = new JButton("Rectangle");
gbc.ipadx = 2; 
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 1;
g.setConstraints(rect,gbc);
panel.add(rect);
circle = new JButton("Circle");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 2;
g.setConstraints(circle,gbc);
panel.add(circle);
poly = new JButton("Polygon");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 3;
g.setConstraints(poly,gbc);
panel.add(poly);
ellipse = new JButton("Ellipse");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 4;
g.setConstraints(ellipse,gbc);
panel.add(ellipse);
line = new JLabel("select line color");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 1;
g.setConstraints(line,gbc);
panel.add(line);
kid = new JLabel("");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 2;
g.setConstraints(kid,gbc);
panel.add(kid);
color = new JLabel("select Fill color");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 3;
g.setConstraints(color,gbc);
panel.add(color);
String Line[]={"choose the 

color","Red","Yellow","Green","Blue","Cyan","Manget

a","Orange"};
cbLine = new JComboBox(Line);
gbc.fill= GridBagConstraints.BOTH;
gbc.insets=new Insets(5,5,5,5);
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 1;
g.setConstraints(cbLine,gbc);
panel.add(cbLine);
cil = new JLabel("");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 2;
g.setConstraints(cil,gbc);
panel.add(cil);
String Fill[]={"choose the 

color","Red","Yellow","Green","Blue","Cyan","Manget

a","Orange"};
cbFill = new JComboBox(Fill);
gbc.fill= GridBagConstraints.BOTH;
gbc.insets=new Insets(5,5,5,5);
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 3;
g.setConstraints(cbFill,gbc);
panel.add(cbFill);
Color c =new Color(250,100,100);
Container contentpane= getContentPane();
textAreaPanel = new JPanel(new 

GridLayout(2,1,5,5));
drawTextArea = new JTextArea();
drawScrollPane = new JScrollPane(drawTextArea);
textAreaPanel.add(drawScrollPane);
textAreaPanel.setLayout(g);
textAreaPanel= (JPanel)getContentPane();
contentpane.add(textAreaPanel,BorderLayout.SOUTH);
dateTime();
}
public void dateTime()
{
datimeThread=new Thread(this);
datimeThread.start();
}
public void run()
{
while(datimeThread !=null)
{
display();
try
{
datimeThread.sleep(1000);
}
catch(InterruptedException  e)
{
showStatus("Thread interrupted");
}
}
}
public void display()
{
date =new Date();
calendar =new GregorianCalendar();
calendar.setTime(date);
strTime = 

calendar.get(Calendar.HOUR)+":"+calendar.get(Calend

ar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strDate= 

(calendar.get(Calendar.MONTH)+1)+"/"+calendar.get(C

alendar.DATE)+"/"+calendar.get(Calendar.YEAR);
strStatus=strTime+" "+strDate;
showStatus(strStatus);
setSize(700,500);   
setVisible(true);
}
}           
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.event.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class MyPaint extends JApplet implements 

Runnable  
{
/* Declaring the variables.*/
JPanel panel;
JPanel textAreaPanel;
JTextArea drawTextArea;
JScrollPane drawScrollPane;
JLabel line, color, paint,kid,cil;
JButton circle, rect, poly, ellipse;
JComboBox cbLine, cbFill;
GridBagLayout g;
GridBagConstraints gbc;
Thread datimeThread;
Date date;
GregorianCalendar calendar;
String strDate, strTime, strStatus;
public void init()
{
g=new GridBagLayout();  
gbc=new GridBagConstraints();
panel= (JPanel)getContentPane();
panel.setLayout(g);
paint = new JLabel("My Paint Application");
gbc.anchor= GridBagConstraints.NORTH;
gbc.gridx =2;
gbc.gridy = 0;
g.setConstraints(paint,gbc);
panel.add(paint);
rect = new JButton("Rectangle");
gbc.ipadx = 2; 
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 1;
g.setConstraints(rect,gbc);
panel.add(rect);
circle = new JButton("Circle");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 2;
g.setConstraints(circle,gbc);
panel.add(circle);
poly = new JButton("Polygon");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 3;
g.setConstraints(poly,gbc);
panel.add(poly);
ellipse = new JButton("Ellipse");
gbc.ipadx = 2;
gbc.ipady = 2;
gbc.gridy = 1;
gbc.gridx = 4;
g.setConstraints(ellipse,gbc);
panel.add(ellipse);
line = new JLabel("select line color");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 1;
g.setConstraints(line,gbc);
panel.add(line);
kid = new JLabel("");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 2;
g.setConstraints(kid,gbc);
panel.add(kid);
color = new JLabel("select Fill color");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 2;
gbc.gridx = 3;
g.setConstraints(color,gbc);
panel.add(color);
String Line[]={"choose the 

color","Red","Yellow","Green","Blue","Cyan","Manget

a","Orange"};
cbLine = new JComboBox(Line);
gbc.fill= GridBagConstraints.BOTH;
gbc.insets=new Insets(5,5,5,5);
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 1;
g.setConstraints(cbLine,gbc);
panel.add(cbLine);
cil = new JLabel("");
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 2;
g.setConstraints(cil,gbc);
panel.add(cil);
String Fill[]={"choose the 

color","Red","Yellow","Green","Blue","Cyan","Manget

a","Orange"};
cbFill = new JComboBox(Fill);
gbc.fill= GridBagConstraints.BOTH;
gbc.insets=new Insets(5,5,5,5);
gbc.ipadx = 4;
gbc.ipady = 4;
gbc.gridy = 3;
gbc.gridx = 3;
g.setConstraints(cbFill,gbc);
panel.add(cbFill);
Color c =new Color(250,100,100);
Container contentpane= getContentPane();
textAreaPanel = new JPanel(new 

GridLayout(2,1,5,5));
drawTextArea = new JTextArea();
drawScrollPane = new JScrollPane(drawTextArea);
textAreaPanel.add(drawScrollPane);
textAreaPanel.setLayout(g);
textAreaPanel= (JPanel)getContentPane();
contentpane.add(textAreaPanel,BorderLayout.SOUTH);
dateTime();
}
public void dateTime()
{
datimeThread=new Thread(this);
datimeThread.start();
}
public void run()
{
while(datimeThread !=null)
{
display();
try
{
datimeThread.sleep(1000);
}
catch(InterruptedException  e)
{
showStatus("Thread interrupted");
}
}
}
public void display()
{
date =new Date();
calendar =new GregorianCalendar();
calendar.setTime(date);
strTime = 

calendar.get(Calendar.HOUR)+":"+calendar.get(Calend

ar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strDate= 

(calendar.get(Calendar.MONTH)+1)+"/"+calendar.get(C

alendar.DATE)+"/"+calendar.get(Calendar.YEAR);
strStatus=strTime+" "+strDate;
showStatus(strStatus);
setSize(700,500);   
setVisible(true);
}
}           

pls,the own Daniweb forum should assist on this exception.

C:\z>appletviewer MyPaint.html
java.lang.IllegalArgumentException: adding container's parent to itself
        at java.awt.Container.addImpl(Container.java:611)
        at java.awt.Container.add(Container.java:518)
        at MyPaint.init(MyPaint.java:121)
        at sun.applet.AppletPanel.run(AppletPanel.java:348)
        at java.lang.Thread.run(Thread.java:536)