private static JLayeredPane getLayeredPane(Window window) {
    if (window instanceof JFrame) {
      return ((JFrame) window).getRootPane().getLayeredPane();
    } else if (window instanceof JDialog) {
      return ((JDialog) window).getRootPane().getLayeredPane();
    }

    return null;
  }
private static JLayeredPane getLayeredPane(Window window)