I have a jpanel and some components(JButton) and now I want to access that button from another class. I want to disable/enable that button from another class. The button variable is private. If I extend will I able to access? Is it possible to use super keyword? I have tried some way but it is not working. Please give some suggestion.
Asked
Active
Viewed 25 times
0
-
What do you think `private` means and how it is supposed to work? Would not be very private if everybody could access it. – luk2302 Oct 12 '22 at 18:34
-
1No. If you need to access it from a child, then it needs to be `protected`. If you need to access it in an unrelated class, then it needs to be `public`. – Tim Roberts Oct 12 '22 at 18:35
-
would you please give some examples? – Hasibul Hasan Chowdhury Oct 12 '22 at 18:48
-
Click on the first duplicate. – luk2302 Oct 12 '22 at 19:08