Start: Applet not initialized
HI im still learning how to use java, my code doesn't have any errors but it says it's not initialized can some look at it and see what i did wrong
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JPanel;
public class Person extends JPanel implements MouseListener
{
{
this.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { if (turnsleft > 0)
showNext();
else reset();
}});}
private int turnsleft;
public int getNumLeft() {
return turnsleft;
}
public void reset(){
turnsleft = 6;
repaint();
}
public void showNext(){
turnsleft = turnsleft -1;
repaint();
}
public void init()
{
this.setSize(500, 400);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
this.setBackground(Color.YELLOW);
if (turnsleft < 1)
{
g.setColor(new Color(11, 56, 176));
g.fillOval(250, 70, 40, 40);
}
if (turnsleft <2)
{
g.setColor(Color.BLUE);
g.fillRect(190,100,125,125);
}
if (turnsleft <3)
{
g.setColor(Color.BLUE);
g.fillRect(300,80,80,50);
}
if (turnsleft <4)
{
g.setColor(Color.BLUE);
g.fillRect(125,80,80,50);
}
if (turnsleft <5)
{
g.setColor(Color.BLUE);
g.fillRect(290,220,60,70);
}
if (turnsleft <6)
{
g.setColor(Color.BLUE);
g.fillRect(155,220,60,70);
}
if (turnsleft <7)
{
g.setColor(Color.BLUE);
g.fillRect(120,50,50,50);
}
if (turnsleft <8)
{
g.setColor(Color.BLUE);
g.fillRect(335,50,50,50);
}
if (turnsleft <9)
{
g.setColor(Color.BLUE);
g.fillRect(190,100,125,125);
}
if (turnsleft <10)
{
g.setColor(Color.BLUE);
g.fillRect(150,260,67,30);
}
if (turnsleft <11)
{
g.setColor(Color.BLUE);
g.fillRect(286,260,67,30);
}
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
Re: Start: Applet not initialized
Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
What is the complete error message and what line does the error occur?
Re: Start: Applet not initialized
Moved from New to Java.
Before you re-post your code using code tags, please learn how to format it according to the conventions: Code Conventions for the Java Programming Language: Contents
db