8283706: Add final or sealed modifier to appropriate javax.swing API classes

Reviewed-by: darcy, psadhukhan, aivanov, serb
This commit is contained in:
Phil Race 2022-04-08 21:30:12 +00:00
parent 3357d9a168
commit eab4c0c499
6 changed files with 25 additions and 15 deletions

View File

@ -1479,7 +1479,10 @@ public class GroupLayout implements LayoutManager2 {
* @see #createParallelGroup
* @since 1.6
*/
public abstract class Group extends Spring {
public abstract sealed class Group extends Spring
permits ParallelGroup,
SequentialGroup {
// private int origin;
// private int size;
List<Spring> springs;
@ -1758,7 +1761,7 @@ public class GroupLayout implements LayoutManager2 {
* @see #createSequentialGroup
* @since 1.6
*/
public class SequentialGroup extends Group {
public final class SequentialGroup extends Group {
private Spring baselineSpring;
SequentialGroup() {
@ -2454,7 +2457,9 @@ public class GroupLayout implements LayoutManager2 {
* @see #createBaselineGroup(boolean,boolean)
* @since 1.6
*/
public class ParallelGroup extends Group {
public sealed class ParallelGroup extends Group
permits BaselineGroup {
// How children are layed out.
private final Alignment childAlignment;
// Whether or not we're resizable.
@ -2654,7 +2659,7 @@ public class GroupLayout implements LayoutManager2 {
* An extension of {@code ParallelGroup} that aligns its
* constituent {@code Spring}s along the baseline.
*/
private class BaselineGroup extends ParallelGroup {
private final class BaselineGroup extends ParallelGroup {
// Whether or not all child springs have a baseline
private boolean allSpringsHaveBaseline;

View File

@ -54,7 +54,7 @@ import javax.swing.event.MenuKeyListener;
* @author Rich Schiavi
* @since 1.2
*/
public class ToolTipManager extends MouseAdapter implements MouseMotionListener {
public final class ToolTipManager extends MouseAdapter implements MouseMotionListener {
Timer enterTimer, exitTimer, insideTimer;
String toolTipText;
Point preferredLocation;

View File

@ -1362,7 +1362,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
* LayoutManager for JSplitPanes that have an orientation of
* HORIZONTAL_SPLIT.
*/
public class BasicHorizontalLayoutManager implements LayoutManager2
public sealed class BasicHorizontalLayoutManager implements LayoutManager2
permits BasicVerticalLayoutManager
{
/* left, right, divider. (in this exact order) */
/**
@ -2142,7 +2143,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* VERTICAL_SPLIT.
*
*/
public class BasicVerticalLayoutManager extends
public non-sealed class BasicVerticalLayoutManager extends
BasicHorizontalLayoutManager
{
/**

View File

@ -45,7 +45,11 @@ import javax.swing.Icon;
*
* @author Timothy Prinzing
*/
public class StyleConstants {
public sealed class StyleConstants
permits StyleConstants.CharacterConstants,
StyleConstants.ColorConstants,
StyleConstants.FontConstants,
StyleConstants.ParagraphConstants {
/**
* Name of elements used to represent components.
@ -800,7 +804,7 @@ public class StyleConstants {
* attributes that contribute to a paragraph style. These are
* aliased by the outer class for general presentation.
*/
public static class ParagraphConstants extends StyleConstants
public static final class ParagraphConstants extends StyleConstants
implements AttributeSet.ParagraphAttribute {
private ParagraphConstants(String representation) {
@ -813,7 +817,7 @@ public class StyleConstants {
* attributes that contribute to a character style. These are
* aliased by the outer class for general presentation.
*/
public static class CharacterConstants extends StyleConstants
public static final class CharacterConstants extends StyleConstants
implements AttributeSet.CharacterAttribute {
private CharacterConstants(String representation) {
@ -826,7 +830,7 @@ public class StyleConstants {
* attributes that contribute to a color. These are aliased
* by the outer class for general presentation.
*/
public static class ColorConstants extends StyleConstants
public static final class ColorConstants extends StyleConstants
implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute {
private ColorConstants(String representation) {
@ -839,7 +843,7 @@ public class StyleConstants {
* attributes that contribute to a font. These are aliased
* by the outer class for general presentation.
*/
public static class FontConstants extends StyleConstants
public static final class FontConstants extends StyleConstants
implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute {
private FontConstants(String representation) {

View File

@ -35,7 +35,7 @@ import java.net.URL;
* @author Denis Sharypov
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public class FormSubmitEvent extends HTMLFrameHyperlinkEvent {
public final class FormSubmitEvent extends HTMLFrameHyperlinkEvent {
/**
* Represents an HTML form method type.

View File

@ -1832,7 +1832,7 @@ public class StyleSheet extends StyleContext {
* is maintained according to the CSS attributes.
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class BoxPainter implements Serializable {
public static final class BoxPainter implements Serializable {
BoxPainter(AttributeSet a, CSS css, StyleSheet ss) {
this.ss = ss;
@ -2093,7 +2093,7 @@ public class StyleSheet extends StyleContext {
* are being cached.
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class ListPainter implements Serializable {
public static final class ListPainter implements Serializable {
ListPainter(AttributeSet attr, StyleSheet ss) {
this.ss = ss;