Firing delay between JFrame components

后端 未结 2 1732
无人及你
无人及你 2020-12-22 00:08

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

2条回答
  •  执笔经年
    2020-12-22 00:34

    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.

提交回复
热议问题