Reputation: 81
I have a JPanel inside JScrollPane. Inside the JPanel are numerous JButtons. However, these JButtons are set to NOT VISIBLE (jbutton.setVisible(false)) when the JPanel and JScrollPanel are initialized. The JButtons are only set to VISIBLE (jbutton.setVisible(true)) when another class triggers this.
However, although these JButtons are getting successfully added and set to visible on the JPanel, they are not visible on the JPanel or JScrollPane. My guess is that when the JScrollPane adds the JButtons, the JButtons are set to NOT VISIBLE, and even if the JButtons are set to VISIBLE, the JScrollPane does not detect they are.
Is there a way of dynamically changing the visibility of the JButtons in the JPanel inside the JScrollPane?
Upvotes: 2
Views: 1265
Reputation: 109823
However, although these JButtons are getting successfully added and set to visible on the JPanel, they are not visible on the JPanel or JScrollPane. My guess is that when the JScrollPane adds the JButtons, the JButtons are set to NOT VISIBLE, and even if the JButtons are set to VISIBLE, the JScrollPane does not detect they are.
have to call revalidate()
and repaint()
to JPanel
, as last code lines after all changes are executed
have to change setUnitIncrement
for JButtons
in JPanel
wrapped in JScrollPane
, because scrolling is too slow, isn't natural
Upvotes: 3