[SOLVED] MouseClicked event not registering on a certain button

I’m really stuck on this stupid bug. I’ve tried absolutely everything to fix it. I made my own dialog box with 3 buttons and some text. It lets you choose a size for my game’s layout. The two buttons that let you change the size work perfectly, but the “ok” button doesn’t even register.

This is the dialog box

Here’s the code:
http://pastebin.java-gaming.org/7a843088283

Ok… so where do you ever call mouseClicked() then? We need all the relevant code, not short little snippets.

Hopefully this should cover it all
http://pastebin.java-gaming.org/a8438128386

Typo? :
public BTN_Go btnGo = new BTN_Go(“btn_go.png”);
public BTN_Go btnStop = new BTN_Go(“btn_stop.png”);

Should that second line be BTN_Stop?

That’s fine. It’s meant to be like that. I just have messy coding.

It looks like you set some variables like “active” in the mouse handlers on the AWT thread and then access them on your other thread. When you do this you need to set the variables to volatile or use some other form of serialization. This is because of the visibility limitations in the java memory model, so each thread can keep a local copy of any variable and they may or may not sync the local copys until there is a memory barrier. Volatile read/write or synchronize statements cause these memory barriers.

So try changing the “active” variable to be volatile and see if that changes anything.

I tried it and it didn’t work.

You did not include the code to your Entity class, but I think it may be because you redefine these int variables in the DialogBTN class and you set them instead of setting the x,y,w,and h in the Entity superclass. So you have to remove these variables in DialogBTN and make the ones in the superclass public or protected or set the Entity fields with “super.x = …”

public class DialogBTN extends Entity
{
public int x, y, w, h;

I just found out what was wrong. I wasn’t meant to redefine those x,y,w,h variables lol. Just a silly simple mistake.