I'm working on a little code. JFrame
containing a JPanel
with specific dimensions. Here is my code:
import javax.swing.*;
import java.awt.*;
public class ScrollPane extends JFrame {
public ScrollPane() {
super("Title");
setLayout(new BorderLayout());
setSize(320,240);
JScrollPane scroller = new JScrollPane(new DrawingPane());
scroller.setPreferredSize(new Dimension(320,240));
add(scroller);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
private class DrawingPane extends JPanel {
public DrawingPane(){
super();
setSize(640,480);
setMinimumSize(new Dimension(320,240));
}
}
public static void main(String[] args) {
new ScrollPane();
}
}
Even with a minimum size set for the JPanel
, the scrolls don't appear.