Wrapping HTML text in a JEditorPane inside a JScrollPane

前端 未结 2 929
生来不讨喜
生来不讨喜 2020-12-16 07:50

In an application, I\'m using uneditable JEditorPanes as a sort of a generic UI widget that can display somewhat complex content (HTML will do the trick), wrap text lines an

相关标签:
2条回答
  • 2020-12-16 08:16

    The scrollbars of a JScrollPane appear if the size of the viewport become smaller than the preferred size of its view component. Set the preferred size of the panel in the scroll pane, or set the preferred size of each of the editor panes : the preferred size of the panel will be the composition of the preferred sizes of the editor panes (sum of the preferred height, and max of the preferred widths)

    0 讨论(0)
  • 2020-12-16 08:33
    // JPanel panel = new JPanel();
    ScrollablePanel panel = new ScrollablePanel();
    panel.setScrollableWidth( ScrollablePanel.ScrollableSizeHint.FIT );
    

    See Scrollable Panel for the class and an explanation on how the class works.

    0 讨论(0)
提交回复
热议问题