我需要提取 JScrollPane 的面板
I need to extract the panel of my JScrollPane
我需要知道哪种方法可以从我的 scrollpane
中为您提供面板 panelA
。
例如,我有:
PanelExample panelA = new PanelExample();
JScrollPane scrollpane = new JScrollPane(panelA,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollpane.getPanel(); //???
scrollpane.getComponent(); //???
我猜应该是get
方法,但我不知道
您从 JScrollPane
的 JViewport
中获取组件:
Component c = scrollPane.getViewport().getView();
阅读 How to Use Scroll Panes 上的 Swing 教程部分,了解有关滚动窗格如何工作以及滚动窗格布局中涉及的组件的信息。
我需要知道哪种方法可以从我的 scrollpane
中为您提供面板 panelA
。
例如,我有:
PanelExample panelA = new PanelExample();
JScrollPane scrollpane = new JScrollPane(panelA,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollpane.getPanel(); //???
scrollpane.getComponent(); //???
我猜应该是get
方法,但我不知道
您从 JScrollPane
的 JViewport
中获取组件:
Component c = scrollPane.getViewport().getView();
阅读 How to Use Scroll Panes 上的 Swing 教程部分,了解有关滚动窗格如何工作以及滚动窗格布局中涉及的组件的信息。