Search code examples
javaswingjscrollpanejscrollbar

Difference between JScrollBar and JScrollPane


What are the differences between JScrollBar and JScrollPane?


Solution

  • This image is self-explainatory

    enter image description here

    The JViewport provides a window, or "viewport" onto a data source -- for example, a text file. That data source is the "scrollable client" (aka data model) displayed by the JViewport view. A JScrollPane basically consists of JScrollBars, a JViewport, and the wiring between them, as shown in the diagram at right.

    JScrollPane api