/* * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.awt.event; import java.awt.AWTEvent; import java.awt.Adjustable; import java.io.Serial; import java.lang.annotation.Native; /** * The adjustment event emitted by Adjustable objects like * {@link java.awt.Scrollbar} and {@link java.awt.ScrollPane}. * When the user changes the value of the scrolling component, * it receives an instance of {@code AdjustmentEvent}. *
* An unspecified behavior will be caused if the {@code id} parameter * of any particular {@code AdjustmentEvent} instance is not * in the range from {@code ADJUSTMENT_FIRST} to {@code ADJUSTMENT_LAST}. *
* The {@code type} of any {@code AdjustmentEvent} instance takes one of the following * values: *
This method throws an * {@code IllegalArgumentException} if {@code source} * is {@code null}. * * @param source The {@code Adjustable} object where the * event originated * @param id An integer indicating the type of event. * For information on allowable values, see * the class description for {@link AdjustmentEvent} * @param type An integer indicating the adjustment type. * For information on allowable values, see * the class description for {@link AdjustmentEvent} * @param value The current value of the adjustment * @throws IllegalArgumentException if {@code source} is null * @see #getSource() * @see #getID() * @see #getAdjustmentType() * @see #getValue() */ public AdjustmentEvent(Adjustable source, int id, int type, int value) { this(source, id, type, value, false); } /** * Constructs an {@code AdjustmentEvent} object with the * specified Adjustable source, event type, adjustment type, and value. *
This method throws an * {@code IllegalArgumentException} if {@code source} * is {@code null}. * * @param source The {@code Adjustable} object where the * event originated * @param id An integer indicating the type of event. * For information on allowable values, see * the class description for {@link AdjustmentEvent} * @param type An integer indicating the adjustment type. * For information on allowable values, see * the class description for {@link AdjustmentEvent} * @param value The current value of the adjustment * @param isAdjusting A boolean that equals {@code true} if the event is one * of a series of multiple adjusting events, * otherwise {@code false} * @throws IllegalArgumentException if {@code source} is null * @since 1.4 * @see #getSource() * @see #getID() * @see #getAdjustmentType() * @see #getValue() * @see #getValueIsAdjusting() */ public AdjustmentEvent(Adjustable source, int id, int type, int value, boolean isAdjusting) { super(source, id); adjustable = source; this.adjustmentType = type; this.value = value; this.isAdjusting = isAdjusting; } /** * Returns the {@code Adjustable} object where this event originated. * * @return the {@code Adjustable} object where this event originated */ public Adjustable getAdjustable() { return adjustable; } /** * Returns the current value in the adjustment event. * * @return the current value in the adjustment event */ public int getValue() { return value; } /** * Returns the type of adjustment which caused the value changed * event. It will have one of the following values: *