Java JPanel inside JScrollPane?

后端 未结 5 1193
自闭症患者
自闭症患者 2020-12-06 10:06

I have a JFrame, in this JFrame I have a JPanel that I draw on, this Panel can be any size and so I placed it into a JScrollpane to let me scroll when the panel is larger th

5条回答
  •  抹茶落季
    2020-12-06 10:38

    As far as I remember there are 2 options:

    • define the preferredSize of _ImageCanvas
    • create a subclass of JPanel and implement Scrollable: http://docs.oracle.com/javase/7/docs/api/javax/swing/Scrollable.html

    For more details, see the Javadoc: http://docs.oracle.com/javase/7/docs/api/javax/swing/JScrollPane.html

提交回复
热议问题