import java.awt.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.File;
import java.util.*;
/*
<Applet Code="MyPaint.class" width=400 height=400>
</Applet>
*/
public class MyPaint extends JApplet
{
/* 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;
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","Mangeta","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","Mangeta","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);
}
public static void main(String[] args)
{
MyPaint mp = new MyPaint();
mp.setSize(700,500);
mp.setVisible(true);
}
}

Recommended Answers

All 2 Replies

You cannot run an Applet using main(String [] args)
You must use an HTML page.
And I think I've seen the same question to another thread, that had the same answer.

Please don't start multiple threads for the exact same question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.