java leaf on the button



  • ...

    I have a window like this, I need the courseor to be placed on the lower "Veighti" button, and it's lighted and it could be pressed. ♪ ♪ With the button, I did it with the help of:

    if(GamePanel.mouseX > GamePanel.WIDTH / 2 - buttonWidthContinue/ 2 && GamePanel.mouseX < GamePanel.WIDTH / 2 + buttonWidthContinue / 2 && GamePanel.mouseY > GamePanel.HEIGHT / 2 - buttonHeightContinue / 2 && GamePanel.mouseY < GamePanel.HEIGHT / 2 + buttonHeightContinue / 2){
                transP = 60; //Подсветка
                if (GamePanel.leftMouse){
                    GamePanel.state = GamePanel.STATES.PLAY;
                }
            } else {
                transP = 0; // Удаление подсветки
            }
    

    But here's how I don't know what to do with the bottom button, if I don't understand anything, then go ahead. ♪ ♪



  • If the button is the object of Button (or JButton), then it is worth adding ActionListener to handle the claws and mice. If these buttons are just painted (which is likely to be so), it's like the first button, process the second button. I recommend the use of objects, even though they are self-sustained, rather than painted solutions, because they are much easier to communicate, for example, to make the whole logic of appeal into the method isPressed() and to avoid duplication of the code.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2