Reputation: 49
I would like to know how to smooth the automatic transition of a JScrollPane. I'm using
JScrollBar scroll = scollpane.getVerticalScrollBar();
scroll.setValue(scroll.getMaximum());
Something like JScrollPane.setUnitIncrement(inc)
with inc values of ~0.001 and a 10ms delay between increments would help, I guess, but setUnitIncrement
only takes int
s.
Also, I want the same smooth animation for adding an element like JList
to a JPanel
with BoxLayout
. I'd like it to have a smooth top-to-bottom appearance, not instantly being displayed when using JPanel.add(JList)
.
I'm mostly looking towards an implementation of AurelienRibon's SlidingLayout
or Tween
, but I can't wrap my head around it.
Upvotes: 0
Views: 228
Reputation: 6441
Smooth animations (any type, in any program) are done with implementations of Delta-Time
.
Most frameworks use a Delta-Time
pattern (the ones that don't are doing it wrong, because other methods are prone to Time-Drifting
bugs), and are hard to understand if you don't grasp the concept of Delta-Time
first.
Upvotes: 1