frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
// Register a listener for when the window is resizing so that we can resize the
// internal frames. The HierarchyBoundsListener gets events while it is resizing,
// whereas the ComponentListener only gets them after the resize.
frame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsAdapter(){
@Override
public void ancestorResized(HierarchyEvent e) {
// Start by checking that the internal frame will fit and adjust if required.
PictureFrame pictureFrame = app.getPictureFrame();
Dimension desktopSize = app.getDesktopPane().getSize();