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);
}
}

Recommended Answers

All 3 Replies

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

What are the error messages?

What are the error messages?

We are suppossed to guess and then we get a prize

Richard

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.