< prev index next >
src/java.desktop/share/classes/java/awt/Component.java
Print this page
*** 2700,2713 ****
}
return new Dimension(dim);
}
/**
! * Sets the minimum size of this component to a constant
! * value. Subsequent calls to {@code getMinimumSize} will always
! * return this value. Setting the minimum size to {@code null}
! * restores the default behavior.
*
* @param minimumSize the new minimum size of this component
* @see #getMinimumSize
* @see #isMinimumSizeSet
* @since 1.5
--- 2700,2714 ----
}
return new Dimension(dim);
}
/**
! * Sets the minimum size of this component to a constant value.
! * If the value is greater than maximum size, then maximum size is also
! * set to this value. Subsequent calls to {@code getMinimumSize} will
! * always return this value.
! * Setting the minimum size to {@code null} restores the default behavior.
*
* @param minimumSize the new minimum size of this component
* @see #getMinimumSize
* @see #isMinimumSizeSet
* @since 1.5
*** 2717,2733 ****
// If the minimum size was set, use it as the old value, otherwise
// use null to indicate we didn't previously have a set minimum
// size.
if (minSizeSet) {
old = this.minSize;
! }
! else {
old = null;
}
this.minSize = minimumSize;
minSizeSet = (minimumSize != null);
firePropertyChange("minimumSize", old, minimumSize);
}
/**
* Returns whether or not {@code setMinimumSize} has been
* invoked with a non-null value.
--- 2718,2745 ----
// If the minimum size was set, use it as the old value, otherwise
// use null to indicate we didn't previously have a set minimum
// size.
if (minSizeSet) {
old = this.minSize;
! } else {
old = null;
}
this.minSize = minimumSize;
minSizeSet = (minimumSize != null);
firePropertyChange("minimumSize", old, minimumSize);
+ if (isMaximumSizeSet() && minimumSize != null) {
+ Dimension lMaxSize = getMaximumSize();
+ if (lMaxSize.width < minimumSize.width) {
+ lMaxSize.width = minimumSize.width;
+ }
+ if ( lMaxSize.height < minimumSize.height) {
+ lMaxSize.height = minimumSize.height;
+ }
+ if (!maxSize.equals(lMaxSize)) {
+ setMaximumSize(lMaxSize);
+ }
+ }
}
/**
* Returns whether or not {@code setMinimumSize} has been
* invoked with a non-null value.
*** 2773,2786 ****
}
return new Dimension(dim);
}
/**
! * Sets the maximum size of this component to a constant
! * value. Subsequent calls to {@code getMaximumSize} will always
! * return this value. Setting the maximum size to {@code null}
! * restores the default behavior.
*
* @param maximumSize a {@code Dimension} containing the
* desired maximum allowable size
* @see #getMaximumSize
* @see #isMaximumSizeSet
--- 2785,2799 ----
}
return new Dimension(dim);
}
/**
! * Sets the maximum size of this component to a constant value.
! * If the value is smaller than minimum size, then maximum size is
! * set to minimum size. Subsequent calls to {@code getMaximumSize}
! * will return this or corrected value.
! * Setting the maximum size to {@code null} restores the default behavior.
*
* @param maximumSize a {@code Dimension} containing the
* desired maximum allowable size
* @see #getMaximumSize
* @see #isMaximumSizeSet
*** 2791,2804 ****
// use null to indicate we didn't previously have a set maximum
// size.
Dimension old;
if (maxSizeSet) {
old = this.maxSize;
! }
! else {
old = null;
}
this.maxSize = maximumSize;
maxSizeSet = (maximumSize != null);
firePropertyChange("maximumSize", old, maximumSize);
}
--- 2804,2825 ----
// use null to indicate we didn't previously have a set maximum
// size.
Dimension old;
if (maxSizeSet) {
old = this.maxSize;
! } else {
old = null;
}
+ if (isMinimumSizeSet() && maximumSize != null) {
+ Dimension lMinSize = getMinimumSize();
+ if (maximumSize.width < lMinSize.width) {
+ maximumSize.width = lMinSize.width;
+ }
+ if (maximumSize.height < lMinSize.height) {
+ maximumSize.height = lMinSize.height;
+ }
+ }
this.maxSize = maximumSize;
maxSizeSet = (maximumSize != null);
firePropertyChange("maximumSize", old, maximumSize);
}
< prev index next >