开发者

JScrollPane not resizing when added to JPanel

开发者 https://www.devze.com 2023-04-09 04:18 出处:网络
I cant get the scrollPane to resize correctly when added to the scrollPanel. I want the scrollPane to scale to the size of the sc开发者_如何学GorollPanel. Any tips?

I cant get the scrollPane to resize correctly when added to the scrollPanel. I want the scrollPane to scale to the size of the sc开发者_如何学GorollPanel. Any tips?

public class MTabbedPane_HomePanel extends JPanel {
    private JPanel scrollPanel;
    private JScrollPane scrollPane;

    public MTabbedPane_HomePanel()
    {
        init();
        makePanel();
    }

    private void init() {
        scrollPanel             = new JPanel();
        scrollPane              = new JScrollPane(scrollPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    }

    private void makePanel() {
        IAppWidgetFactory.makeIAppScrollPane(scrollPane);
        setLayout(new BorderLayout());
        scrollPane.setBorder(null);
        add(scrollPane, BorderLayout.CENTER);
    }
}


your code is correct, maybe

  • try to disable UIDelegate from IAppWidgetFactory.makeIAppScrollPane(), if remains unchanged

then

  • check how you added (if is used LayoutManager) for MTabbedPane_HomePanel to the parent


Call setPreferredSIze() for the panel.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号