How to have a Scrollable JTextPane?

前端 未结 5 2072
余生分开走
余生分开走 2021-01-07 22:22

I would like to have a JTextPane that have scroll bar, how can I do so ? Thanks.

5条回答
  •  时光说笑
    2021-01-07 23:03

    Before this just add a ScrollPane to ContentPane in Design and add EditopPane to ScrollPane as child

    JScrollPane sp = (JScrollPane)contentPane.getComponent(23);//this is in my hierarchy 23
    JViewport vp = sp.getViewport();
    JEditorPane ep = (JEditorPane)vp.getView();
    

提交回复
热议问题