code: private void addModal(Component component, ModalListener listener,
  						Integer modalDepth) {
  	if (modalDepth == null) {
  	  modalDepth = defaultModalDepth;
  	}
  	if (components.contains(component) == false) {
  
  	  rootPane.getLayeredPane().remove(getModalPanel());
  	  rootPane.getLayeredPane().add(getModalPanel(), modalDepth);
  
  	  KeyboardFocusManager focusManager =
  		  KeyboardFocusManager.getCurrentKeyboardFocusManager();
  	  focusManager.clearGlobalFocusOwner();
  	  getModalPanel().removeAll();
  	  getModalPanel().add("", component);
  	  resizeModalPanel();
  	  getModalPanel().repaint();
  	  components.add(component);
  	  depths.put(component, modalDepth);
  	  addListener(component, listener);
  	}
    }
docs: Add a modal component
  
  @param component
  {@link Component}
  @param listener
  {@link ModalListener}
  @param modalDepth