1 /* 2 * Copyright (c) 2002-2025 Gargoyle Software Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * https://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 package org.htmlunit; 16 17 /** 18 * A listener for WebWindowEvent's. 19 * <p> 20 * This listener informs when a new window is opened, when the content of a window changes 21 * or when a window is closed. 22 * </p> 23 * <p> 24 * Caution: The WebClient creates (and opens) the initial window as part of the construction 25 * process. This implies, the initial window is already open at the time you attach this listener. 26 * Therefore you will receive no open event for this. 27 * </p> 28 * 29 * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a> 30 * @author Ronald Brill 31 */ 32 public interface WebWindowListener { 33 34 /** 35 * A web window has been opened. 36 * <p>Caution: the {@link WebClient#getCurrentWindow()} might be not updated so far. 37 * This usually takes place AFTER the event was processed</p> 38 * 39 * @param event the event (the oldPage and newPage properties will be {@code null} 40 * because the event is generated after the window is opened but before the content is loaded) 41 */ 42 void webWindowOpened(WebWindowEvent event); 43 44 /** 45 * The contents of a web window has been changed. 46 * 47 * @param event the event 48 */ 49 void webWindowContentChanged(WebWindowEvent event); 50 51 /** 52 * A web window has been closed. Closing the last window of the WebClient will automatically open 53 * a new one. You will receive an additional open event in this case. 54 * 55 * @param event the event 56 */ 57 void webWindowClosed(WebWindowEvent event); 58 } 59