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 JFrame
{
/* 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);
}
}
fatjoy25
0
Newbie Poster
Recommended Answers
Jump to PostThat isn't an applet. It's a JFrame. You cannot run a JFrame as an applet.
Jump to PostHow are you trying to run it and what is the exact text of the message. Remember that you cannot run applets with the normal "java MyPaint" command.
All 6 Replies
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
fatjoy25
0
Newbie Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
majestic0110
187
Nearly a Posting Virtuoso
barevhayerable
-4
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
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.