int x = (int) (Math.random() * screenDimension.width) - internalFrame2.getWidth();
x = Math.max(x,internalFrame1.getWidth());
int y = (int) (Math.random() * screenDimension.height) - internalFrame2.getHeight();
y = Math.max(y,internalFrame1.getHeight());
internalFrame2.setLocation(x,y);
internalFrame2.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosed(InternalFrameEvent e) {
removeInternalFrame(internalFrame2);
}
});
openInternalFrame(internalFrame2);