Can't see components in JScrollPane

前端 未结 1 1243
我在风中等你
我在风中等你 2021-01-28 15:11

I\'m using a JScrollPane to hold a JTextArea for a large area of text. I add the TextArea directly to the JFrame, it works fine. But I add it to the scrollpane and add the scrol

相关标签:
1条回答
  • 2021-01-28 16:02

    Assuming textPane is a JScrollPane, you should never be adding components to it.

    Instead use JScrollPane#setViewportView(Component)

    JScrollPane is made of a number components which work together to provide you the functionality required to make the component scrollable...

    enter image description here

    JScrollPane has a JViewport, which is used to contain the component you want to be scrolled. You need to "apply" the component to the view.

    Take a closer look at How to use Scroll Panes for more details

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