yaykittyeee's Profile User Rating: -----

Reputation: 2 Apprentice
Active Members
Active Posts:
59 (0.03 per day)
16-September 10
Profile Views:
Last Active:
User is offline Jun 19 2014 11:31 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Dream Kudos:

Latest Visitors

Icon   yaykittyeee has not set their status

Posts I've Made

  1. In Topic: Trying to get sound to play when it is suppose play

    Posted 23 Oct 2013

    if you post a link to your updated project, I can take a look at it
  2. In Topic: Java Looping problems

    Posted 22 Oct 2013

    when you are waiting for the user's input you can use the following to check that the user's input will be a certain type

    Scanner in = new Scanner(System.in);
    int num = 0;
    while(!hasNextInt()){//you can also use hasNextFloat() or hasNextDouble()
    System.out.println("Please input an integer.  Try again.");
    num = in.nextInt();

    or you can use a try/catch block to catch a NumberFormatException or something that will display an error message then quit the program.
  3. In Topic: Trying to get sound to play when it is suppose play

    Posted 21 Oct 2013

    I took a look at your code. I think the problem of the sound being played repeatedly is because you are constantly rendering it, so every time it is rendered and passes the if statement and the mouse is hovering over a button it will play that sound. You need to make MainMenu and other classes that need to implement this hover sound "implement MouseListener"


    you might want to try reading up on event listeners to understand how they work and try googling adding mouselisteners to graphic objects.

    Also, I don't think you should be constantly rendering a screen that doesn't have graphics that need to move. For instance, a menu that is waiting for the user to press a button should not be constantly re-rendered. I was going to try and do this to your project to show you what I'm talking about, but I ran out of time.

    Also, I noticed you are drawing all five buttons each time drawButton is called. It would be better to draw one at a time.

    	public void render(Graphics g){
    		g.drawImage(Images.main_menu_background, 0, 0, GameConstants.WIDTH, GameConstants.HEIGHT, null);
    		g.drawImage(Images.main_menu_title, 0, 0, GameConstants.WIDTH, GameConstants.HEIGHT, null);
    		play.x -= 3;
    		play.y -= 9;
    		drawButton(g, play, Images.main_menu_play_normal);
    		options.x -= 3;
    		options.y -= 7;
    		drawButton(g, options, Images.main_menu_options_normal);
    		instructions.x -= 3;
    		instructions.y -= 10;
    		drawButton(g, instructions, Images.main_menu_instructions_normal);
    		scores.x -= 3;
    		scores.y -= 9;
    		drawButton(g, scores, Images.main_menu_high_scores_normal);
    		quit.x -= 2;
    		quit.y -= 12;
    		drawButton(g, quit, Images.main_menu_quit_normal);

    drawButton will look like this and it will draw each button.

    	public void drawButton(Graphics g, Rectangle rect, Image img){
        	g.drawImage(img, rect.x, rect.y, null);

    when you implement MouseListener, you will have to implement the necessary methods such as mouseClicked for when the button is clicked. The following should execute one sound for each click. You will also need to implement the other methods and put the same thing in mouseEntered for hovering. mouseEntered is also where you'll put your code to change the image to a hover image. mouseExited should change the image back to the normal image.

      public void mouseClicked( MouseEvent e ) {
        if ((e.getButton() == 1) && (play.contains(e.getX(), e.getY())
            || options.contains(e.getX(), e.getY()) 
            || instructions.contains(e.getX(), e.getY()) 
            || scores.contains(e.getX(), e.getY())
            || quit.contains(e.getX(), e.getY()) ) ){
            new ClickSound();
          }catch (LineUnavailableException | InterruptedException ie) {

    I hope the tips helped, I didn't have time to finish a rendering example.
  4. In Topic: comparator, sorting by multiple properties

    Posted 17 Oct 2013

    I don't really understand it. I thought a comparator compared object1 with object2 and should return a positive number if object1 is greater than object2 and a negative number if object1 is less than object2 and a 0 if they are equivalent. However, I fixed this problem by switch the 1 and -1 return values.

    instead of:
        rVal = 1;
    }else if(!stu1.isEnrolled()&&stu2.isEnrolled()){
        rVal = -1;
        rVal = stu1.getFullName().compareTo(stu2.getFullName());

    i used:
        rVal = -1;
    }else if(!stu1.isEnrolled()&&stu2.isEnrolled()){
        rVal = 1;
        rVal = stu1.getFullName().compareTo(stu2.getFullName());

    I guess I'm missing something. I don't understand why, but it works.
  5. In Topic: comparator, sorting by multiple properties

    Posted 15 Oct 2013

    actually it is sorting by enrollment first, but for some reason it is putting the non enrolled list of students at the top of the list and the enrolled students at the bottom.

My Information

Member Title:
D.I.C Head
Age Unknown
April 22
computers, music, final fantasy
Years Programming:
Programming Languages:
Java, C, C++, OpenGL

Contact Information



yaykittyeee hasn't added any friends yet.


Page 1 of 1
  1. Photo

    rtester Icon

    25 Oct 2013 - 14:34
    Thanks your post helped me and my friend figure my problem out! with the sound and my menu.
Page 1 of 1