0

So I am trying to make a JButton get activated without it being actually pressed. However, I want this action to be performed only if a rectangle-jcomponent is touched by my player. How can I achieve this? Can I check if the position of my player is the same with the one I need and then maybe use a boolean to activate the button :?

Here's how I have handled a "normal" click on the button. Now I additionally want the button to be activated, if the player touches the end-goal...

buttonarea.goal_1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cl.show(frame.getContentPane(), "Goal 1 WON");
                gamingarea.getPanel().requestFocusInWindow();                       
            }
            
        });
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
FishyK
  • 121
  • 1
  • 7

0 Answers0