diff --git a/src/java.desktop/share/classes/javax/swing/JComponent.java b/src/java.desktop/share/classes/javax/swing/JComponent.java
index d1b1313ebb4..352fefeaacb 100644
--- a/src/java.desktop/share/classes/javax/swing/JComponent.java
+++ b/src/java.desktop/share/classes/javax/swing/JComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -1739,10 +1739,13 @@ public abstract class JComponent extends Container implements Serializable,
/**
* Sets the maximum size of this component to a constant
- * value. Subsequent calls to getMaximumSize will always
+ * value. Subsequent calls to {@code getMaximumSize} will always
* return this value; the component's UI will not be asked
- * to compute it. Setting the maximum size to null
+ * to compute it. Setting the maximum size to {@code null}
* restores the default behavior.
+ *
+ * Subclasses may choose to override this by returning their own maximum size
+ * in the {@code getMaximumSize} method.
*
* @param maximumSize a Dimension containing the
* desired maximum allowable size
@@ -1780,10 +1783,13 @@ public abstract class JComponent extends Container implements Serializable,
/**
* Sets the minimum size of this component to a constant
- * value. Subsequent calls to getMinimumSize will always
+ * value. Subsequent calls to {@code getMinimumSize} will always
* return this value; the component's UI will not be asked
- * to compute it. Setting the minimum size to null
+ * to compute it. Setting the minimum size to {@code null}
* restores the default behavior.
+ *
+ * Subclasses may choose to override this by returning their own minimum size + * in the {@code getMinimumSize} method. * * @param minimumSize the new minimum size of this component * @see #getMinimumSize diff --git a/src/java.desktop/share/classes/javax/swing/JScrollBar.java b/src/java.desktop/share/classes/javax/swing/JScrollBar.java index ba65f21a954..761d4672031 100644 --- a/src/java.desktop/share/classes/javax/swing/JScrollBar.java +++ b/src/java.desktop/share/classes/javax/swing/JScrollBar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -753,11 +753,41 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible } } - // PENDING(hmuller) - the next three methods should be removed + /** + * Unlike most components, {@code JScrollBar} derives the minimum size from + * the preferred size in one axis and a fixed minimum size in the other. + * Thus, it overrides {@code JComponent.setMinimumSize} contract + * that subsequent calls to {@code getMinimumSize} will return the + * same value as set in {@code JComponent.setMinimumSize}. + * + * @param minimumSize the new minimum size of this component + */ + public void setMinimumSize(Dimension minimumSize) { + super.setMinimumSize(minimumSize); + } /** - * The scrollbar is flexible along it's scrolling axis and + * Unlike most components, {@code JScrollBar} derives the maximum size from + * the preferred size in one axis and a fixed maximum size in the other. + * Thus, it overrides {@code JComponent.setMaximumSize} contract + * that subsequent calls to {@code getMaximumSize} will return the + * same value as set in {@code JComponent.setMaximumSize}. + * + * @param maximumSize the desired maximum allowable size + */ + public void setMaximumSize(Dimension maximumSize) { + super.setMaximumSize(maximumSize); + } + + /** + * Returns the minimum size for the {@code JScrollBar}. + * The scrollbar is flexible along its scrolling axis and * rigid along the other axis. + * As specified in {@code setMinimumSize} JScrollBar will derive the + * minimum size from the preferred size in one axis and a + * fixed minimum size in the other. + * + * @return the minimum size as specified above */ public Dimension getMinimumSize() { Dimension pref = getPreferredSize(); @@ -769,8 +799,14 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible } /** - * The scrollbar is flexible along it's scrolling axis and + * Returns the maximum size for the {@code JScrollBar}. + * The scrollbar is flexible along its scrolling axis and * rigid along the other axis. + * As specified in {@code setMaximumSize} JScrollBar will derive the + * maximum size from the preferred size in one axis and a + * fixed maximum size in the other. + * + * @return the maximum size as specified above */ public Dimension getMaximumSize() { Dimension pref = getPreferredSize();