How to I use a ScrollBar object to control horizontal scrolling of the data in my chart?
Since the ChartView class is derived from JPanel, you can place the scroll bar in the ChartView object, or you can place the ChartView object and the scroll bar in a parent container and use a layout manager to position everything. If you place the scroll bar in the ChartView you can still position it using a layout manager. The ChartView will always use the entire content area of the underlying JPanel for its canvas and the scroll bars will sit on top of this, not side by side. The example program swingexamples.LinePlotScrollBar uses two scroll bars, a horizontal scroll bar to control scrolling of the x-axis, and a vertical scroll bar that controls the magnitude of the y-axis. You need to implement the AdjustmentListener interface for the derived ChartView in order to process the adjustmentValueChanged method invoked when the scrollbars are moved. public void updateXScaleAndAxes(int index) { int startindex = 0; startindex = jScrollBar1.getValue(); pTransform1.setScaleStartX( (double)
Related Questions
- When I click on "Win Control" from the Jeyo Remote menu on my mobile phone, all I get is a horizontal scrolling bar. How do I control my PC?
- I thought you said that ordinal data can be converted to interval data for the purpose of creating a control chart. How is that done?
- How to I use a ScrollBar object to control horizontal scrolling of the data in my chart?