0

So I have this issue when I clean and build my project, my button doesn't call any methods that it is supposed to call. It only works when I run the program in the NetBeans IDE. The weird part is my other buttons work but this one doesn't. Here is my code there is nothing wrong with it, I just don't know why this is happening.

private void btnPlayMouseReleased(java.awt.event.MouseEvent evt) {                                      

    btnPlay.setIcon(unpressPlay);
    // Goes to ChoiceFrame
    ChoiceFrame displayPick = new ChoiceFrame();
    // Makes GameFrame visible
    displayPick.setVisible(true);
    // Close the previous window
    //callPlay();
    dispose();
}  
Cmi
  • 479
  • 2
  • 5
  • 12
  • What exactly do you mean by *clean and build my project,*? Do you use a framework like `maven` maybe? – Naman Sep 23 '17 at 02:03
  • @nullpointer Never heard of maven but clean and build makes my project have a .jar, so I can just run the .jar and it will run like a desktop application – Cmi Sep 23 '17 at 02:08
  • if icon is in resources folder you should use `getResource` funtion – Madhawa Priyashantha Sep 23 '17 at 02:11
  • @FastSnail I do that ImageIcon pressPlay = new ImageIcon(getClass().getResource("/images/playPressed.png")); it works for my other buttons, just not this one I don't know why – Cmi Sep 23 '17 at 02:13
  • @Cmi so you can't even see the button with icon?check this question https://stackoverflow.com/questions/6845231/how-to-correctly-get-image-from-resources-folder-in-netbeans – Madhawa Priyashantha Sep 23 '17 at 02:27
  • @FastSnail I can see the button it's just the when I click on it, it does nothing even though there is code. – Cmi Sep 23 '17 at 02:39
  • Are you sure the event you have your code in is even getting fired. Place a: `System.out.println("Play Button Selected!");` code line into the event to see if it's even getting fired. Curious, why not just use the **ActionPerformed** event? – DevilsHnd - 退職した Sep 23 '17 at 02:57
  • @DevilsHnd that doesn't work either, I am using a JLabel as my button because, I designed how the button looks like. I did try with an actual button and that didn't work. I don't know why this error is happening. – Cmi Sep 23 '17 at 12:26
  • What didn't work either? Did you try to see if the event is even getting fired? And what is the Error? – DevilsHnd - 退職した Sep 24 '17 at 03:57
  • @DevilsHnd my event gets fired but doesn't call my class – Cmi Sep 25 '17 at 13:47

0 Answers0