Resizing issue with canvas within jscrollpane within jsplitpane

Instead of setPreferredSize(), let your components calculate their own preferred size and pack() the enclosing Window to accommodate. The example below adds an instance of draw.GraphPanel to the top and a corresponding control panel to the bottom. import draw.GraphPanel; import java.awt.EventQueue; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; /** * @see https://stackoverflow.com/q/11942961/230513 … Read more