I want to show how merge sort perform visually using JFrame
. What I want to do is to make visible subsequent JLabel
with some time delay. I tried m
You need to update the icons in the timer's action listener, as shown here. You can implement the Icon
interface to render icons having a size proportional to an element's comparative value, as shown here.
Addendum: Can you please be little bit specific?
You want to animate the intermediate steps of sorting a List
of size N
in some initially random order. Number
subclasses implement Comparable
, so compareTo()
is already done. A GridLayout(1, 0)
of JLabel
each having an Icon
can be used to display the values. DecRenderer shows how to create icons with a proportional size; you'll want to vary the height over the interval [0, N)
. GrayIcons & Mad's example show how to animate the display of the icons in some order.