91 | | |
| 91 | = Usage, Example |
| 92 | Usage is very simple, basically the same as standard java panels but you always need to create a model. We look at the [source:mvc/src/test/java/tudelft/utilities/mvc/panels/SliderPanelTest.java] example: |
| 93 | {{{ |
| 94 | RestrictedNumberModel model = new RestrictedNumberModel( |
| 95 | new BigDecimal("1.2"), |
| 96 | new NumberModel(new BigDecimal("1.1"), log), |
| 97 | new NumberModel(new BigDecimal("1.3"), log), log); |
| 98 | panel.add(new SliderPanel(model), BorderLayout.CENTER); |
| 99 | panel.add(new NumberPanel(model), BorderLayout.SOUTH); |
| 100 | |
| 101 | }}} |
| 102 | |
| 103 | We left out the standard boilerplate to create the window. |
| 104 | The RestrictedNumberModel is initialized with the number 1.2, and the range is set to [1.1, 1.3]. |
| 105 | Then we add a SliderPanel and a NumberPanel, both showing the same number. This allows the user to change the number either by dragging the slider or by typing the exact number. |
| 106 | |
| 107 | There are many more examples in the |