0

Please, someone, help me out to check the errors in this code. What is the proble? I'm new to Java applet and I'm using notepad. I copied this code from a site to test but it is not working with me in the notepad and command prompt.

import java.applet.*;
import java.awt.*;

Public class DrawExample extends Applet
{... See More
public void init()
{
bigFont=new Font("Arial",Font.Bold, 16);
redColor=Color.red;
bgColor=Color.blue;
setBackground(bgColor);
}
public void stop()
{
}
public void paint(Graphics g)
{
g.setFont(bigFont);
g.drawString("Shapes and Colors",80,20);
g.setColor(redColor);
g.drawRect(100,100,100,100);
g.fillRect(110,110,80,80);
g.setColor(weirdColor);
g.fillArc(120,120,60,60,0,360);
g.setcolor(Color.yellow);
g.drawLine(140,140,160,160);
g.setColor(Color.black);
}
}

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by freesoft_2000
0

First use Programmer's tools (Notepad++, IDEs et al).
Secondly use code tags
And now back to your question:
1. Stop copy-paste and ask, try to understand what is happening
2. Explain what you want to accomplish/Learn
3. You have copied only part of the code, see "{... See More" in your copied code
4. Link to where you copied otherwise that is unfair to original writer of the code (Unless he allowed it to be posted anywhere anyhow)

Do the above and everybody will be happy to help

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.