mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
6510914: JScrollBar.getMinimumSize() breaks the contract of JComponent.setMinimumSize()
Reviewed-by: abhiscxk, prr
This commit is contained in:
parent
7004c2724d
commit
39627bc429
@ -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 <code>getMaximumSize</code> 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 <code>null</code>
|
||||
* to compute it. Setting the maximum size to {@code null}
|
||||
* restores the default behavior.
|
||||
* <p>
|
||||
* Subclasses may choose to override this by returning their own maximum size
|
||||
* in the {@code getMaximumSize} method.
|
||||
*
|
||||
* @param maximumSize a <code>Dimension</code> 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 <code>getMinimumSize</code> 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 <code>null</code>
|
||||
* to compute it. Setting the minimum size to {@code null}
|
||||
* restores the default behavior.
|
||||
* <p>
|
||||
* 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
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user