public void update(MouseEvent event) {
        int mask = (event.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK);
        boolean buttonDown = mask == MouseEvent.BUTTON1_DOWN_MASK;

        if (pressed && !buttonDown) {
            pressed = false;
            callback.invoke();
            return;
        }

        if (event.getX() >= rect.x && event.getX() <= rect.x + rect.width
         && event.getY() >= rect.y && event.getY() <= rect.y + rect.height)
            hover = true;
        else
            hover = false;

        if (hover && buttonDown)
            pressed = true;
        else
            pressed = false;
    }