Java JPanel inside JScrollPane?

后端 未结 5 1204
自闭症患者
自闭症患者 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:42

    // suggest a size of 'canvas'
    _ImageCanvas.setPreferredSize(new Dimension(100,100));
    
    // Scroll pane smaller then the size of the canvas so we should get scroll bars right?
    _ScrollPane.setPreferredSize(new Dimension(50,50)); 
    
    // ..later 
    _Frame.pack();
    

提交回复
热议问题