Deal or No Deal as a Java GUI Error/Problem

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1860 Views - Last Post: 20 May 2012 - 02:17 PM Rate Topic: -----

#1 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:08 AM

I am trying to create a deal or no deal game in java (gui version). The problem is, I don't know how to implement the MouseListener so that when the user clicks the briefcase gif, it will change into another briefcase gif. In other words, the GUI will start running, and when the user clicks on a closed briefcase I would like it to change into an open briefcase. How do I do that????? I have already "imported" my gifs. And here is my code so far. Don't have much.

import javax.swing.JFrame;

public class Breifcase
{
   //-----------------------------------------------------------------
   //  Creates and displays the application frame.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      JFrame frame = new JFrame ("Briefcase");
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

      frame.getContentPane().add (new BriefcasePanel());

      frame.pack();
      frame.setVisible(true);
   }
}



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class BriefcasePanel extends JPanel
{
   private final int WIDTH = 300, HEIGHT = 200;
   private final int IMAGE_SIZE = 20;

   private ImageIcon open, close,currentImage;
   private int x, y;

   //-----------------------------------------------------------------
   //  Constructor: Sets up this panel and loads the images.
   //-----------------------------------------------------------------
   public DirectionPanel()
   {
      addMouseListener (new BriefcaseListener());

      x = WIDTH / 2;
      y = HEIGHT / 2;

      open = new ImageIcon ("caseOpen.gif");
      close = new ImageIcon ("caseClose.gif");
      

      currentImage = close;

      setBackground (Color.black);
      setPreferredSize (new Dimension(WIDTH, HEIGHT));
      setFocusable(true);
   }

   //-----------------------------------------------------------------
   //  Draws the image in the current location.
   //-----------------------------------------------------------------
   public void paintComponent (Graphics page)
   {
      super.paintComponent (page);
      currentImage.paintIcon (this, page, x, y);
   }

   //*****************************************************************
   //  Represents the listener for mouse activity.
   //***************************************************************** 
   private class BriefcaseListener implements MouseListener
   {
       public void mouseClicked (MouseEvent event)
       { 
       switch ((int)event.getPoint()) 
       {
           case MouseEvent.getPoint: 
                currentImage=open;
                break;
           case MouseEvent.getPoint:
                currentImage=close;
                break;
       }
       repaint(); 
    }
    public void mousePressed (MouseEvent event) {}
    public void mouseReleased (MouseEvent event) {}
    public void mouseEntered (MouseEvent event) {}
    public void mouseExited (MouseEvent event) {}
   }
}



Now, the error message that I am getting is where I have: switch ((int)event.getPoint()), it says inconvertible types found :java.awt.Point required: int. So I put a random integer in getPoint() when I did that it gave me an error message saying, getPoint() in java.awt.event.MouseEvent cannot be applied to (int). So I take t=out the type casting and now have switch (event.getPoint(320)) and it gives me the same error message . I have no idea what to do now and the error messages just keep going in circles. Please can you help? Code would be nice to have.

Is This A Good Question/Topic? 0
  • +

Replies To: Deal or No Deal as a Java GUI Error/Problem

#2 Benzoate  Icon User is offline

  • D.I.C Head


Reputation: 51
  • View blog
  • Posts: 233
  • Joined: 29-February 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:19 AM

http://docs.oracle.c...selistener.html

I suggest looking over this :)
Was This Post Helpful? 0
  • +
  • -

#3 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:26 AM

Benzoate I looked over the link and I understand what they are doing. But I don't know how to apply that into changing a gif. How do I set it up so that instead of sayingSomething it actually changes the gif???
Was This Post Helpful? 0
  • +
  • -

#4 Benzoate  Icon User is offline

  • D.I.C Head


Reputation: 51
  • View blog
  • Posts: 233
  • Joined: 29-February 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:33 AM

I would suggest when having clicked the case, have currentImage switched to open, that should display the open case.

If you posted your new code, I could probably help you a lot better :) (also if you posted the images, that would help as well)
Was This Post Helpful? 0
  • +
  • -

#5 Swillis57  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 31
  • Joined: 14-January 11

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:33 AM

You're getting that error because you can't cast a Point to an int, and Point is what getPoint() returns:

Quote

getPoint()
Returns the x,y position of the event relative to the source component


What you could do is first get the Point of the event and store it in a Point variable, and then check to see if it's within the bounds of your Briefcase image using x and y, something like this:

Point eventPoint = event.getPoint();

//pseudocode, cannot check a range like this in Java
if (BriefcaseGif.getLocation().getX() < eventPoint.getX() < (BriefcaseGif.getWidth() + BriefcaseGif.getLocation().getX())){
  //nested if to make the line above shorter
  if (BriefcaseGif.getLocation().getY() < eventPoint.getY() < (BriefcaseGif.getHeight() + BriefcaseGif.getLocation().getY())){
    //change pictures
  }
}





Now, there is probably a much easier way of doing this, but this was the first one I could think of. As an alternative, you could use JButtons instead of Image objects (I assume those are what you're using currently), apply the image to the button, and add this as an actionListener to the button, but without all the checks to see if the click was within the bounds of the image.
Was This Post Helpful? 1
  • +
  • -

#6 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:49 AM

Swillis57 thank you! I have added your code in in replacing the switch. Now I am getting an error saying that BriefCasePanel.BriefcaseListener is not abstract and does not override abstract method mouseExited (java.awt.event.MouseEvent) in java.awt.event.MouseListener.



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class BriefcasePanel extends JPanel
{
   private final int WIDTH = 300, HEIGHT = 200;
   private final int IMAGE_SIZE = 20;

   private ImageIcon open, close,currentImage;
   private int x, y;

   //-----------------------------------------------------------------
   //  Constructor: Sets up this panel and loads the images.
   //-----------------------------------------------------------------
   public BriefcasePanel()
   {
      addMouseListener (new BriefcaseListener());

      x = WIDTH / 2;
      y = HEIGHT / 2;

      open = new ImageIcon ("caseOpen.gif");
      close = new ImageIcon ("caseClose.gif");
      

      currentImage = close;

      setBackground (Color.black);
      setPreferredSize (new Dimension(WIDTH, HEIGHT));
      setFocusable(true);
   }

   //-----------------------------------------------------------------
   //  Draws the image in the current location.
   //-----------------------------------------------------------------
   public void paintComponent (Graphics page)
   {
      super.paintComponent (page);
      currentImage.paintIcon (this, page, x, y);
   }

   //*****************************************************************
   //  Represents the listener for mouse activity.
   //***************************************************************** 
   private class BriefcaseListener implements MouseListener
   {
       public void mouseClicked (MouseEvent event)
       { 
           Point eventPoint = event.getPoint();
 
           //pseudocode, cannot check a range like this in Java
            if (open.getLocation().getX() < eventPoint.getX() < (open.getWidth() + open.getLocation().getX()))
            {
                //nested if to make the line above shorter
                if (close.getLocation().getY() < eventPoint.getY() < (close.getHeight() + close.getLocation().getY()))
                {
                    //change pictures
                }

            }
       }
     
    }
    public void mousePressed (MouseEvent event) {}
    public void mouseReleased (MouseEvent event) {}
    public void mouseEntered (MouseEvent event) {}
 
   }

Was This Post Helpful? 0
  • +
  • -

#7 Benzoate  Icon User is offline

  • D.I.C Head


Reputation: 51
  • View blog
  • Posts: 233
  • Joined: 29-February 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:53 AM

just add
public void mouseExited(MouseEvent event){}



that should fix it.
Was This Post Helpful? 0
  • +
  • -

#8 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 07:55 AM

Benzoate tried that get the exact same error message????
Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,466
  • Joined: 27-December 08

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 12:27 PM

Did you include that in your BriefcaseListener class? Make sure you implement all the MouseListener methods as well.
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 17 May 2012 - 05:35 PM

View PostSwillis57, on 17 May 2012 - 10:33 AM, said:

Point eventPoint = event.getPoint();

//pseudocode, cannot check a range like this in Java
if (BriefcaseGif.getLocation().getX() < eventPoint.getX() < (BriefcaseGif.getWidth() + BriefcaseGif.getLocation().getX())){
  //nested if to make the line above shorter
  if (BriefcaseGif.getLocation().getY() < eventPoint.getY() < (BriefcaseGif.getHeight() + BriefcaseGif.getLocation().getY())){
    //change pictures
  }
}


Not sure an if with 2 < inside it is valid :)

As far as the abstract error is concerned you have a } coming too soon

   private class BriefcaseListener implements MouseListener 
   {
       public void mouseClicked (MouseEvent event)
       { 
           Point eventPoint = event.getPoint();
 
           //pseudocode, cannot check a range like this in Java
            if (open.getLocation().getX() < eventPoint.getX() < (open.getWidth() + open.getLocation().getX()))
            {
                //nested if to make the line above shorter
                if (close.getLocation().getY() < eventPoint.getY() < (close.getHeight() + close.getLocation().getY()))
                {
                    //change pictures
                }

            }
       }
     
   }   // <--------- you finish the class too early here
   
    // the following methods should be in that class

    public void mousePressed (MouseEvent event) {}
    public void mouseReleased (MouseEvent event) {}


Was This Post Helpful? 0
  • +
  • -

#11 Swillis57  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 31
  • Joined: 14-January 11

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 18 May 2012 - 07:08 AM

The if-block I provided was pseudocode, I only used it to demonstrate an idea, it wasn't meant to be used in the program. You can't use two "<" within the if-statement. They have to be expanded to this to work:


Point eventPoint = event.getPoint();

//actual code
if (BriefcaseGif.getLocation().getX() < eventPoint.getX() && eventPoint.getX() < (BriefcaseGif.getWidth() + BriefcaseGif.getLocation().getX())){
  //nested if to make the line above shorter
  if (BriefcaseGif.getLocation().getY() < eventPoint.getY() && eventPoint.getY()(BriefcaseGif.getHeight() + BriefcaseGif.getLocation().getY())){
    //change pictures
  }
}



You also need to create the picture-switching code, I'm not sure exactly how you've designed the program, so I can't make an accurate representation of it.
And make sure you add the two methods that pbl said, so that it meets the full requirements of the interface and you don't have to make it an abstract class.
Was This Post Helpful? 0
  • +
  • -

#12 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 20 May 2012 - 01:05 PM

Okay so I have another post where I ask for specific help with changing a gif into another gif with a user mouse click. Even though the replies were great and had a lot of useful information, I was not able to get it working. So i diverged and programed a text based version of deal or no deal and got that working in no time. So what I am asking is if you could look at my text based could and what I have so far for my GUI code and tell me (or give m code) to help me with the GUI. Now I am not asking you to do my homework, because actually the assignment was to just mak a text based version. The GUI version is something that I am doing extra. So if you could please tell me where I am going wrong or give me code I will be forever grateful.

Here is my text based:

--------------------Main Class--------------------------------

import java.io.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.*;

public class DealOrNoDealMain {
    // Create a single shared BufferedReader for keyboard input
    private static BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
    static NumberFormat nf = NumberFormat.getInstance();
    static ArrayList<Case> caseList;
    static ArrayList<Double> moneyList;
    static String board =   "\n-------------------------------------------------\n"
+ "$0.01                                             $1,000\r\n" +
    "$1                                              $5,000\r\n" +
    "$5                                             $10,000\r\n" +
    "$10                                            $25,000\r\n" +
    "$25    [21] [22] [23] [24] [25] [26]           $50,000\r\n" +
    "$50  [14] [15] [16] [17] [18] [19] [20]        $75,000\r\n" +
    "$75    [7] [8] [9] [10] [11] [12] [13]        $100,000\r\n" +
    "$100      [1] [2] [3] [4] [5] [6]             $200,000\r\n" +
    "$200                                          $300,000\r\n" +
    "$300                                          $400,000\r\n" +
    "$400                                          $500,000\r\n" +
    "$500                                          $750,000\r\n" +
    "$750                                           $1,000,000 " +
    "\n-------------------------------------------------";
    // Program execution starts here
    public static void main(String[] args) throws IOException, ParseException{

        System.out.println("\t  Welcome to Deal or No Deal!");
        // Initialize cases with random values
        init();
        // Prompt user for case to keep

        System.out.println(board);
        System.out.println("\nChoose one case. This will be YOUR case.");

        int specialCaseIndex = promptCase(-2);
        caseList.get(specialCaseIndex).open();
        updateBoard(specialCaseIndex, "specialcase");
        String currentDeal = "";
        for(int i = 4; i+2 > 1; i--){
            for(int casesToOpen = i+2; casesToOpen > 0; casesToOpen--){

                System.out.println(board);
                System.out.println("Round: " + (i+2) + "\t\t" + "    Cases left to open: " + casesToOpen);
                if(currentDeal.length() > 0){
                    System.out.println("Deal: $" + currentDeal);
                }
                openCase( promptCase(specialCaseIndex) );
            }
            currentDeal = nf.format(bankerDeal(i+2));
            System.out.println(board);
            System.out.println("\nThe Banker offers you a deal of $" + currentDeal + ".");
            int choice = promptDeal();
            if(choice == 1){
                System.out.println("\n*** Congratulations! You won $" + currentDeal + "! ***");
                System.exit(0);
            }else if(choice == 2){
                System.out.println("\n*** You have declined the Banker's offer. ***");
            }
        }
        for(int i = 0, j = 1; i < 5; i++){
            System.out.println(board);
            System.out.println("Single Round(s)             Cases left to open: " + 1);
            if(currentDeal.length() > 0){

                System.out.println("Deal: $" + currentDeal);
            }
            if(i != 4){
                openCase( promptCase(specialCaseIndex) );
            }else if(i == 4){
                openCase( promptCase(-1) );
                break;
            }
            currentDeal = nf.format(bankerDeal(1));

            System.out.println(board);

            System.out.println("\nThe Banker offers you a deal of $" + currentDeal + ".");

            int choice = promptDeal();
            if(choice == 1){

                System.out.println("\n*** Congratulations! You won $" + currentDeal + "! ***");
                System.exit(0);
            }else if(choice == 2){

                System.out.println("\n*** You have declined the Banker's offer. ***");
            }

        }

        for(int i = 1; i < caseList.size(); i++){

            if(caseList.get(i).isHidden()){

                System.out.println("\nYou opened case " + caseList.get(i).getCaseNum() + " containing " + caseList.get(i).getValue() + ".");
                break;
            }
        }
        System.out.println("\n*** Your case, " + specialCaseIndex + ", contains " + caseList.get(specialCaseIndex).getValue() + "! ***");

        System.out.println("\n*** Congratulations! You won " + caseList.get(specialCaseIndex).getValue() + "! ***");

    }

    public static int promptDeal() throws IOException{

        while(true){

            try{

                System.out.println("\nDEAL OR NO DEAL?");

                System.out.println("1. Deal");

                System.out.println("2. No Deal");

                System.out.print("\nEnter choice: ");

                int choice = Integer.parseInt(kb.readLine().trim());
                if(choice < 1 || choice > 2){
                    System.out.println("\nInvalid input. ");
                }else{
                    return choice;
                }

            }catch(NumberFormatException e){
                System.out.println("\nInvalid input.");
            }
        }
    }

    public static int bankerDeal(int round){

        int numCasesLeft = 0;

        for(int i = 0; i < caseList.size(); i++){
            if(caseList.get(i).isHidden()){

                numCasesLeft++;
            }
        }

        double deal = 0;
        for(int i = 1; i < moneyList.size(); i++){

            deal += ( moneyList.get(i) * (1.0 / numCasesLeft) );

        }

        if (round == 6){

            deal /= 1.75;

        }else if(round == 5){

            deal /= 1.35;

        }

        return (int)deal;

    }

    public static int promptCase(int yourCase) throws IOException{

        while(true){

            try{

                if(yourCase == -1){

                    System.out.print("\nOpen the last case: ");

                }else{

                    System.out.print("\nChoose a case: ");

                }

                int choice = Integer.parseInt(kb.readLine().trim());

                if(choice < 1 || choice > 26){

                    System.out.println("\nInvalid input. Please choose a valid case.");

                }else if(choice == yourCase){

                    System.out.println("\nYou cannot open your case yet!");
                }else if(!caseList.get(choice).isHidden()){
                    System.out.println("\nCase " + choice + " is already open.");

                }else{

                    return choice;
                }
            }catch(NumberFormatException e){
                System.out.println("\nInvalid input. Please choose a valid case.");
            }
        }

    }

 

    public static void openCase(int caseNum) throws ParseException{

        System.out.println("\nYou opened case " + caseNum + " containing " + caseList.get(caseNum).getValue() + ".");

        // Open case

        caseList.get(caseNum).open();

 
       // Remove case value from moneyList
        String casev = caseList.get(caseNum).getValue().substring(1);
        for(int j = 1; j < moneyList.size(); j++ ){

            if(nf.parse(casev).doubleValue() == moneyList.get(j)){

                moneyList.remove(j);

                break;
            }
        }

        // Update board

        updateBoard( caseNum, caseList.get(caseNum).getValue());

    }

    public static void updateBoard(int caseNum, String value) throws ParseException{

        for(int i = 0; i < board.length(); i++){

            String str = "["+caseNum+"]";

            int index = board.indexOf(str);

            if(caseNum < 10){

                board = board.substring(0,index) + "[ ]" + board.substring(index+str.length());

                break;

            }else{

                board = board.substring(0,index) + "[  ]" + board.substring(index+str.length());

                break;

            }

        }

        boolean specialCase = false;

        if(value.equalsIgnoreCase("specialcase")){

            specialCase = true;

        }

        if(!specialCase){

            String str = value;

            int index = board.indexOf(str);

 

            while(Character.isDigit(board.charAt(index+str.length()+1)) || board.charAt(index+str.length()+1) == ','){
                index = board.indexOf(str, index+1);

            }
            String temp = "";

            for(int j = 0; j < str.length(); j++){

                temp += " ";

            }

            board = board.substring(0,index) + temp + board.substring(index+str.length());

        }

    }

    public static void init() throws ParseException{

        String[] values = { "", "0.01", "1", "5", "10", "25", "50", "75", "100", "200", "300", "400", "500", "750",

                "1,000", "5,000", "10,000", "25,000", "50,000", "75,000", "100,000", "200,000", "300,000", "400,000", "500,000", "750,000", "1,000,000" };

 

        caseList = new ArrayList<Case>(27);

        caseList.add(new Case());

        moneyList = new ArrayList<Double>(27);

        moneyList.add(0.0);

        ArrayList<Integer> valuesInserted = new ArrayList<Integer>(27);

        // Create cases

        for(int i = 1; i < 27; i++){

            // Generate a random value

            Random generator = new Random();

            int index = generator.nextInt(27);

            while( exists(index, valuesInserted) || index == 0 ){

                index = generator.nextInt(27);

            }

            // Construct new Case with unique value

            caseList.add( new Case(i, "$"+values[index], true) );

            valuesInserted.add(index);

        }
        for(int i = 1; i < values.length; i++){

            moneyList.add(nf.parse(values[i]).doubleValue());

        }
    }
    // Helper method - Determines whether value has been already inserted

    private static boolean exists(int index, ArrayList<Integer> valuesInserted){

        for(int i = 0; i < valuesInserted.size(); i++){

            if(index == valuesInserted.get(i)){

                return true;

            }

        }

        return false;

    }

}


----------Case Class------------

public class Case {
    private int caseNum;
    private String value;
    private boolean hidden;
    public Case() {
        caseNum = 0;
        value = "";
        hidden = true;
    }
    public Case(int caseNum, String value, boolean hidden){
        this.caseNum = caseNum;
        this.value = value;
        this.hidden = hidden;
    }
    public int getCaseNum(){
        return caseNum;
    }
    public String getValue(){
        return value;
    }
    public boolean isHidden(){

        if(this.hidden){
            return true;
        }
        return false;
    }
    public void open(){
        this.hidden = false;
    }
    public String toString(){
        return caseNum+"";
    }
}



And here is my GUI code not much:

-----BriefCase-----
import javax.swing.JFrame;

public class Briefcase
{
   //-----------------------------------------------------------------
   //  Creates and displays the application frame.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      JFrame frame = new JFrame ("Briefcase");
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

      frame.getContentPane().add (new BriefcasePanel());

      frame.pack();
      frame.setVisible(true);
   }
}


-----------BriefCasePanel-------------

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class BriefcasePanel extends JPanel
{
   private final int WIDTH = 300, HEIGHT = 200;
   private final int IMAGE_SIZE = 20;

   private ImageIcon open, close,currentImage;
   private int stupidX, stupidY;

   //-----------------------------------------------------------------
   //  Constructor: Sets up this panel and loads the images.
   //-----------------------------------------------------------------
   public BriefcasePanel()
   {
      addMouseListener (new BriefcaseListener());

      stupidX = WIDTH / 2;
      stupidY = HEIGHT / 2;

      open = new ImageIcon ("caseOpen.gif");
      close = new ImageIcon ("caseClose.gif");
      

      currentImage = close;

      setBackground (Color.black);
      setPreferredSize (new Dimension(WIDTH, HEIGHT));
      setFocusable(true);
   }

   //-----------------------------------------------------------------
   //  Draws the image in the current location.
   //-----------------------------------------------------------------
   public void paintComponent (Graphics page)
   {
      super.paintComponent (page);
      currentImage.paintIcon (this, page, stupidX, stupidY);
   }
  
   public point getLocation()
   {
       return point;
    }
    public x getX()
    {
        return x;
    }
    public y getY()
    {
        return y;
    }
 
   //*****************************************************************
   //  Represents the listener for keyboard activity.
   //***************************************************************** 
   private class BriefcaseListener implements MouseListener  
   { 
      public void mouseClicked (MouseEvent event)
      {
        Point eventPoint = event.getPoint();
        //actual code
        if (currentImage.getLocation().getX() < eventPoint.getX() && eventPoint.getX() < (currentImage.getWidth() + currentImage.getLocation().getX())){
            //nested if to make the line above shorter
            if (open.getLocation().getY() < eventPoint.getY() && eventPoint.getY()<(open.getHeight() + open.getLocation().getY())){
                //change pictures
            }
        }
     
    
    }
      public void mousePressed (MouseEvent event) {}
      public void mouseReleased (MouseEvent event) {} 
      public void mouseExited (MouseEvent event) {}
      public void mouseEntered (MouseEvent event) {}
  }
}


Error Message: It says that it can't find the class Point. It stops there, it doesn't go through the rest of the code.

PLEASE HELP!!! Help is appreciated.
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,466
  • Joined: 27-December 08

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 20 May 2012 - 01:14 PM

Remember that Java is case-sensitive, so Point needs to be capitalized.
Was This Post Helpful? 0
  • +
  • -

#14 Mystery15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-May 12

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 20 May 2012 - 01:35 PM

View Postmacosxnerd101, on 20 May 2012 - 01:14 PM, said:

Remember that Java is case-sensitive, so Point needs to be capitalized.

whot do you mean post it in the appropiate forum, I thought programming Java was right?????? I did what said about the case sensitivity and it doesn't work???
Was This Post Helpful? 0
  • +
  • -

#15 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,466
  • Joined: 27-December 08

Re: Deal or No Deal as a Java GUI Error/Problem

Posted 20 May 2012 - 01:39 PM

I didn't say anything about posting in the appropriate forum.

Also, look here. First, point as the return type should be Point. Second, there is no point instance or local variable. So I'm not sure what you are trying to return there. And JPanel already has a getLocation() method. Why are you trying to override or overload it? You don't need to.
public point getLocation()
44	   {
45	       return point;
46	    }



Also, I merged your threads. Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2