spinner.adoc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. = spinner
  2. :author:
  3. :revnumber:
  4. :revdate: 2016/03/17 20:48
  5. :relfileprefix: ../../../
  6. :imagesdir: ../../..
  7. ifdef::env-github,env-browser[:outfilesuffix: .adoc]
  8. == Spinner Class
  9. The Spinner class provides:
  10. * A display area for the current step value
  11. * An increment button
  12. * A Decrement button
  13. * It can be set to cycle (when it reaches heighest step value it cycles to index 0, and reversed for decrement.
  14. The Spinner class provides the same 3 common constructors as shown in the <<jme3/contributions/tonegodgui/quickstart#,Quick Start Guide>> with the addition of two extra parameters.
  15. * The orientation of the Spinner
  16. * A boolean flag enabling/disabling Spinner cycling.
  17. The additional parameter are appended to the existing parameter list for all 3 constructors, like so:
  18. [source,java]
  19. ----
  20. /**
  21. * Parameters:
  22. * Screen screen
  23. * String UID
  24. * Vector2f position
  25. * Spinner.Orientation orientation
  26. * boolean cycle
  27. */
  28. Spinner spinner1 = new Spinner(
  29. screen,
  30. “SomeID”,
  31. new Vector2f(15, 15),
  32. Spinner.Orientation.HORIZONTAL,
  33. true
  34. );
  35. ----
  36. === Abstract Event Methods:
  37. [source,java]
  38. ----
  39. public void onChange(int selectedIndex, String value);
  40. ----
  41. === Methods specific to the Spinner class:
  42. [source,java]
  43. ----
  44. // Quickly set interval info for both button
  45. spinner1.setInterval(float callsPerSecond);
  46. // Adding removing list info
  47. spinner1.addStepValue(String value);
  48. spinner1.removeStepValue(String value);
  49. // Quickly populate step values with integers/floats
  50. spinner1.setStepIntegerRange(int min, int max, int inc);
  51. spinner1.setStepFloatRange(float min, float max, float inc);
  52. // Retrieval of current selected step
  53. spinner1.getSelectedIndex();
  54. ----
  55. You can set the select Spinner's displayed and selected value using:
  56. [source,java]
  57. ----
  58. spinner1.setSelectedIndex(int selectedIndex)
  59. ----