JScrollPane not resizing when added to JPanel
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.
加载中,请稍侯......
精彩评论