I am creating a mini project. My project is a library management system.
How can I disable the issue button in advanced search if I am logged in by clicking Anonymus
?
Or how can I enable the issue button if logged in as administrator?
I am creating a mini project. My project is a library management system.
How can I disable the issue button in advanced search if I am logged in by clicking Anonymus
?
Or how can I enable the issue button if logged in as administrator?
You can enable / disable buttons using the setEnabled()
method. You will have to figure out the code for the boolean
that needs to be passed to the method.
Basically, what you need to do is to call setEnabled(isAdministrator())
on your Issues button. For this, you'll have to implement an isAdministrator()
method, which should check if a user is logged in and if that user is the/an administrator. How to check this depends on the implementation of your login dialog and on how you administer your users. Normally you'd have some kind of database holding all users and (encrypted) passwords as well as a flag telling if a certain user is an administrator (or you can have a separate table with roles or permissions and a many-to-many relation between the user table and the roles or permissions table but for a mini-project this is probably not needed).
Just make a boolean variable initialized as false when you validate through username and password change it to true, buttons have a jButton.setVisibility("true or false"); this can either be true or false but adding the boolean variable there will determine whether its a registered user or an anonymous client :)