Help please, some strange errors

Help please, some strange errors

Sorry about this messy formatting. As a beginner in java i got no idea which part of the code is creating this errors so i have posted the whole program here. Here i tried to make the monopoly game of two players with some basic things like moving the player on the game board according to the dice rolled. it even runs and works accurate but after some play the error hits on to the console view. Can someone tell me what in the code is causing that run-time errors? Any kind of help will be helpful to me. and let me know if you want to know more about this because i've not posted the other classes here like Property,Player, main class etc.. I hope i will get some solution here..

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;
import javax.swing.Timer;


public class Board extends JPanel implements ActionListener 
{
    //timer object would call the method actionPerfored at every 25 mili-seconds
    private Timer timer;
    //Create spaces on the game board  
    Property prop[] = new Property[40];
    //Create Players
    Player p[] = new Player[2];
    //some local helpful variables
    int et,  dice1, dice2, pflag;
    static int k;


    Board ()
    {
        //Initialization of all Spaces on the Game Board
        prop[0] = new Property(632, 637, 0, 0, "Go", 1);
        prop[1] = new Property(557, 580, "Mediterranean Avenue", 60, 2);
        prop[2] = new Property(506, 580, 0, 0, "Community Chest", 1);
        prop[3] = new Property(449, 580, "Baltic Avenue", 60, 4);
        prop[4] = new Property(392, 580, 0, 0, "Income Tax", 1);
        prop[5] = new Property(337, 580, "Reading Railroad", 300, 25);
        prop[6] = new Property(283, 580, "Oriental Avenue", 100, 6);
        prop[7] = new Property(227, 580, 0, 0, "Chance", 1);
        prop[8] = new Property(172, 580, "Vermont Avenue", 100, 6);
        prop[9] = new Property(116, 580, "Connecticut Avenue", 120, 8);
        prop[10] = new Property(13, 668, 58, 624, "Just Visiting", 1);
        prop[11] = new Property(100, 565, "St. Charles Place", 140, 10);
        prop[12] = new Property(100, 509, "Electric Company", 150, 0);
        prop[13] = new Property(100, 455, "States Avenue", 140, 10);
        prop[14] = new Property(100, 398, "Virginia Avenue", 160, 12);
        prop[15] = new Property(100, 348, "Pennsylvania Railroad", 300, 25);
        prop[16] = new Property(100, 286, "St. James Place", 180, 14);
        prop[17] = new Property(100, 231, 0, 0, "Community Chest", 1);
        prop[18] = new Property(100, 176, "Tennessee Avenue", 180, 14);
        prop[19] = new Property(100, 119, "New York Avenue", 200, 16);
        prop[20] = new Property(18, 72, 0, 0, "Free Parking", 1);
        prop[21] = new Property(114, 103, "Kentucky Avenue", 220, 18);
        prop[22] = new Property(167, 103, 0, 0, "Chance", 1);
        prop[23] = new Property(223, 103, "Indiana Avenue", 220, 18);
        prop[24] = new Property(279, 103, "Illinois Avenue", 240, 20);
        prop[25] = new Property(332, 103, "B. & O. Railroad", 300, 25);
        prop[26] = new Property(390, 103, "Atlantic Avenue", 260, 22);
        prop[27] = new Property(447, 103, "Ventnor Avenue", 260, 22);
        prop[28] = new Property( 505, 103, "Water Works", 150, 0);
        prop[29] = new Property(559, 103, "Marvin Gardens", 280, 24);
        prop[30] = new Property(637, 47, 0, 0, "Go to Jail", 1);
        prop[31] = new Property(573, 123, "Pacific Avenue", 300, 26);
        prop[32] = new Property(573, 174, "North Carolina Avenue", 300, 26);
        prop[34] = new Property(573, 285, "Pennsylvania Avenue", 320, 28);
        prop[35] = new Property(573, 340, "Short Line", 300, 25);
        prop[36] = new Property(573, 398, 0, 0, "Chance", 1);
        prop[37] = new Property(573, 452, "Park Place", 350, 35);
        prop[38] = new Property(573, 509, 0, 0, "Luxary Tax", 1);
        prop[39] = new Property(573, 563, "Boardwalk", 400, 50);

        //Initialization of the Players
        p[0] = new Player();
        p[1] = new Player();

        addKeyListener (new Al());
        setFocusable(true);
        timer = new Timer(25,this);
        timer.start();

    }

    public void actionPerformed(ActionEvent e)
    {

        repaint();
    }

    public void paint(Graphics g)
    {
        super.paint(g);

        BufferedImage bgImage = readImage("C:/javagame/m.jpg");
        BufferedImage fgImage1 = readImage("C:/javagame/p1.png");
        BufferedImage fgImage2 = readImage("c:/javagame/p2.png");
        BufferedImage overlayedImage;




        overlayedImage = overlayImages (bgImage, fgImage1, fgImage2, prop[p[0].cur].x, prop[p[0].cur].y, prop[p[1].cur].x, prop[p[1].cur].y);


        g.drawImage(overlayedImage,0,0,null);
        g.drawString(String.valueOf(dice1),700,500);
        g.drawString(String.valueOf(dice2),700,510);


    }

    //Here in this method the player's images will be overlayed over the Game Board's Image
    public static BufferedImage overlayImages(BufferedImage bgImage,BufferedImage fgImage1, BufferedImage fgImage2, int x1, int y1, int x2, int y2)
    {
         Graphics2D g2 = bgImage.createGraphics();
         g2.drawImage(bgImage, 0, 0, null);
         g2.drawImage(fgImage1, x1, y1, null);
         g2.drawImage(fgImage2, x2, y2, null); 
         g2.dispose();
         return bgImage;
    }

     public static BufferedImage readImage(String fileLocation)
     {
         BufferedImage img = null;
         try 
         {
             img = ImageIO.read(new File(fileLocation));
         } 
         catch (IOException e) 
         {
             e.printStackTrace();

         }
            return img;
     }

     //Here the Dice Throw Simulation will take place
     public static int roll()
     {
        if (k == 6)
        {
            k = 0;
        }
        k++;
        return k;
     }

     public class Al extends KeyAdapter
     {
         public void keyPressed (KeyEvent e)
         {
             int kc = e.getKeyCode();

             //if  Player has pressed for the R (Dice throw/roll) then roll the dice and move accordingly on the Game Board
             if (kc == KeyEvent.VK_R && et == 0) 
             {
                 et = 1;

                dice1 = roll();
                dice2 = roll();

                p[pflag].cur = p[pflag].cur + dice1 + dice2;

                //If player's position exceeds the 39th space 
                if (p[pflag].cur > 39)
                {
                    p[pflag].cur = p[pflag].cur - 40;
                }

             }

             //If player has pressed for the E then end the current player's turn and pass the turn to the next player
             else if (kc == KeyEvent.VK_E && et == 1)
             {
                  if (pflag == 0)
                  {

                      et = 0;
                      pflag = 1;
                  }

                  else
                  {

                      et = 0;
                      pflag = 0;
                  }
             }



         }


     }




}

Here are those Non stop errors i get ar run-time

at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$700(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Board.paint(Board.java:101)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$700(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
View Answers









Related Tutorials/Questions & Answers:
Help please, some strange errors
Help please, some strange errors  Sorry about this messy formatting... is causing that run-time errors? Any kind of help will be helpful to me. and let... this errors so i have posted the whole program here. Here i tried to make the monopoly
need to fix errors please help
need to fix errors please help  it does have 2 errors what should i...; String name2; System.out.println("please enter your name:"); name1= input.readline(); System.out.println("please enter your friend's name:"); name2
Advertisements
Coding errors for printing function, please help
Coding errors for printing function, please help  Hello, We, my.... Can someone please take a look and help me to fix this. Although...; Please visit the following link: http://www.roseindia.net/java/example/java
PLZ Need some help on the 2nd part of this question...Someone please help !!!!
PLZ Need some help on the 2nd part of this question...Someone please help !!!!  write an application that displays a menue of three items in a restaurant as follows: 1.Cheeseburger 4.99 2.Pepsi 2.00 3.Chips 0.75 prompt the user
Hi Every One , please give me some idia to opning audio File . please Help ..
Hi Every One , please give me some idia to opning audio File . please Help ..  hi Dear Friend , please give me a program to opening audio file... me .please Help
Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming. this is my code... i'm using Turbo C++. It's showing so many errors!.. I don't know what to do. Please help!! #include<iostream.h> void main
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 â?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 â?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 â?? this is the ouput..;;; i
please help
please help  please send me the code of dynamic stack in java without using the built in functions
help please
help please  hi i am done with register application using jsps... shwos some url if copy and paste that url even after i logout from my account... file.. Or atleast help me with code here.. I tried checking session alive
help please?
help please?  Define a class named Circle with the following properties: List item â?¢ An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: â?¢ An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
i am Getting Some errors in Struts - Struts
i am Getting Some errors in Struts   I am Learning Struts Basics,I am Trying examples do in this Site Examples.i am getting lot of errors.Please Help me
Please Help
Please Help  How do I create an attribute that represents the following: A grayscale 'color' value, that is, an integer between 0 and 255 inclusive, where 0 corresponds to the darkest black and 255 to the brightest white
Please Help
Please Help  How do I create an attribute that represents the following: A grayscale â??colorâ?? value, that is, an integer between 0 and 255 inclusive, where 0 corresponds to the darkest black and 255 to the brightest white
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
java please please help
java please please help  Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static...[] to HashMap so that i can seperate key and value using Map.Entry.Please help me!  
help please?
help please?  Define a class named Circle with the following properties: ? An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
please help
please help  public class AllContact extends javax.swing.JFrame { /** Creates new form AllContact */ public AllContact() { initComponents(); try{ Connection1 con =new Connection1(); Connection conobj
Confusion on Functions. Help Please?!
of rectangle and area of cylinder. Right, I've got some of it, but I'm just not getting anywhere with it really :( Some help please...Confusion on Functions. Help Please?!  Write a program which has
Need some help urgently
Need some help urgently  Can someone please help me with this below question. I need to write a class for this. If you roll Y standard six-sided dice... number of possible combinations.   The actual question got some error. Its
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsââ?¬â?¢ names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
New to Java Please help
New to Java Please help  Hi I need help, can some one help me with this. I am currently doing a project. drop me an email to my email address. Thanks!   If you are new in java, then you need to learn core java
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
Java Help Please
Java Help Please  I can't seem to figure out how to make this program, can some one help me please? It is due soon!! 4) Write a program that will take an input (Date object will contain fields for the month, day, and year - all
Please Help Now
Please Help Now  i want to put this map in ajax oriented codeigniter website thanks in advance plz help me now plz very urgent
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Please help me
Please help me  program for when a user enter his card number, it has to create default security pin in the database
PLEASE HELP WITH MY JAVA
PLEASE HELP WITH MY JAVA  Hey my name is Gavin and im a student... please help!!!!!!!! it is a for-loop question: Display the first 5 multiples... and average If u can please help...   
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
please help me
please help me  interface Test1 { String toString(); } public class Test { public static void main(String[] args) { System.out.println(new Test1() { public String toString() { return "test
need help please
need help please  Dear sir, my name is logeswaran. I have a big problem that I can't find the solution for a program. How can I block a user from enter a page second time. Please help me. By the way I'm using Access database
please help me
please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another... before. This name list should get from the database. Please help me. By the way, I'm
help please!!! T_T
help please!!! T_T  what is wrong in this?: import java.io.*; class...("please enter your name:"); name1= input.readline(); System.out.println("please... { String name1; String name2; System.out.println("please enter
please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id? http
please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard and i used [JTextFiled] means that just you can write inside the program (i.e inside the JTextField) but i want to make this program to let me write where i
C Program....PLEASE HELP
, and pointers. I am lost and need a little help starting please *int fillArray...C Program....PLEASE HELP  For this assignment, you are to write a program that calculates points along a rhodonea curve, a.k.a. a mathematical rose

Ads