Is there some way to know if a JScrollBar
is visible or not inside a JPanel
?
I mean, some times, my panel has many rectangles (think of it as buttons) and needs a scrollbar and some times it doesn't need it. I'd like to know if I can know when it is being shown.
If you extend the JPanel
and add yourself the JScrollbar
s (horizontal and/or vertical), then you can control when they must be visible or invisible
(you can check if they are currently visible with the isvisible()
function)
You can find two example of such classes that determine the need for visible scrollbar depending on their content:
JGraphPanel
(its callback actionPerformed(Event e)
will adjust the visibility based on a zoom factor)Plane
(its function adjustComponents()
will call setVisible()
on the JScrollBar
if needed)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With