Custom button set permissions

I have a custom button set permission problem that needs your help.
Customize a delete button in the order list,Set read-only permissions on the order entity.In this case,I hope the delete button is not available.But actually the delete button can still be used:click the delete button,the data disappears,and give the “no access permission” hint,refresh the page,the data appears on the page again,I don’t know how to set the custom button permissions.
I hope I can get your help.
Thank you,

use setEnabled(security.isEntityOpPermitted(Entity.class,EntityOp.DELETE));