可滚动的JPanel
如何使JPanel可滚动?我实现了可滚动的界面,但在将其添加到包含面板时
tabbedPane.add("Editor", new JScrollPane(storeyEditor = new MNScrollablePanel()));
没有任何效果
法典:
public class MNScrollablePanel extends JPanel implements Scrollable {
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
}
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
return 10;
}
public boolean getScrollableTracksViewportHeight() {
return false;
}
public boolean getScrollableTracksViewportWidth() {
return false;
}
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
return 10;
}
}