Summary
-------
Add explicit constructors to API classes of javax.swing.plaf.synth that have default constructors
Problem
-------
Default constructors are not recommended for classes that are parts of a formal API.
Solution
--------
Add explicit public no-arg constructors for public classes and protected no-arg constructor for public abstract classes.
Specification
-------------
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java 2020-08-15 17:34:22.792149000 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java 2020-08-15 17:34:21.332125900 +0530
@@ -58,10 +58,20 @@
new StringUIClientPropertyKey("NoButtonRollover");
/**
+ * Constructs a {@code MetalBorders}.
+ */
+ public MetalBorders() {}
+
+ /**
* The class represents the 3D border.
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class Flush3DBorder extends AbstractBorder implements UIResource{
+ /**
+ * Constructs a {@code Flush3DBorder}.
+ */
+ public Flush3DBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y,
int w, int h) {
if (c.isEnabled()) {
@@ -88,6 +98,11 @@
*/
protected static Insets borderInsets = new Insets( 3, 3, 3, 3 );
+ /**
+ * Constructs a {@code ButtonBorder}.
+ */
+ public ButtonBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if (!(c instanceof AbstractButton)) {
return;
@@ -205,6 +220,11 @@
public static class InternalFrameBorder extends AbstractBorder implements UIResource {
private static final int corner = 14;
+ /**
+ * Constructs a {@code InternalFrameBorder}.
+ */
+ public InternalFrameBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y,
int w, int h) {
@@ -464,6 +484,11 @@
public static class PaletteBorder extends AbstractBorder implements UIResource {
int titleHeight = 0;
+ /**
+ * Constructs a {@code PaletteBorder}.
+ */
+ public PaletteBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
g.translate(x,y);
@@ -490,6 +515,11 @@
public static class OptionDialogBorder extends AbstractBorder implements UIResource {
int titleHeight = 0;
+ /**
+ * Constructs a {@code OptionDialogBorder}.
+ */
+ public OptionDialogBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
g.translate(x,y);
@@ -559,6 +589,11 @@
*/
protected static Insets borderInsets = new Insets( 1, 0, 1, 0 );
+ /**
+ * Constructs a {@code MenuBarBorder}.
+ */
+ public MenuBarBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
g.translate(x, y);
@@ -600,6 +635,11 @@
*/
protected static Insets borderInsets = new Insets( 2, 2, 2, 2 );
+ /**
+ * Constructs a {@code MenuItemBorder}.
+ */
+ public MenuItemBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
if (!(c instanceof JMenuItem)) {
return;
@@ -655,6 +695,11 @@
*/
protected static Insets borderInsets = new Insets( 3, 1, 2, 1 );
+ /**
+ * Constructs a {@code PopupMenuBorder}.
+ */
+ public PopupMenuBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
g.translate( x, y );
@@ -682,6 +727,11 @@
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class RolloverButtonBorder extends ButtonBorder {
+ /**
+ * Constructs a {@code RolloverButtonBorder}.
+ */
+ public RolloverButtonBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
@@ -744,6 +794,11 @@
MetalLookAndFeel.getControlDarkShadow(),
UIManager.getColor("ToolBar.background"));
+ /**
+ * Constructs a {@code ToolBarBorder}.
+ */
+ public ToolBarBorder() {}
+
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h )
{
if (!(c instanceof JToolBar)) {
@@ -876,6 +931,11 @@
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class TextFieldBorder extends Flush3DBorder {
+ /**
+ * Constructs a {@code TextFieldBorder}.
+ */
+ public TextFieldBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y,
int w, int h) {
@@ -903,6 +963,11 @@
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class ScrollPaneBorder extends AbstractBorder implements UIResource {
+ /**
+ * Constructs a {@code ScrollPaneBorder}.
+ */
+ public ScrollPaneBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y,
int w, int h) {
@@ -966,6 +1031,11 @@
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class ToggleButtonBorder extends ButtonBorder {
+ /**
+ * Constructs a {@code ToggleButtonBorder}.
+ */
+ public ToggleButtonBorder() {}
+
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
AbstractButton button = (AbstractButton)c;
ButtonModel model = button.getModel();
@@ -1001,6 +1071,11 @@
public static class TableHeaderBorder extends javax.swing.border.AbstractBorder {
/**
+ * Constructs a {@code TableHeaderBorder}.
+ */
+ public TableHeaderBorder() {}
+
+ /**
* The border insets.
*/
protected Insets editorBorderInsets = new Insets( 2, 2, 2, 0 );
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java 2020-08-15 17:34:32.903658200 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java 2020-08-15 17:34:31.441369800 +0530
@@ -77,6 +77,11 @@
// ********************************
/**
+ * Constructs a {@code MetalButtonUI}.
+ */
+ public MetalButtonUI() {}
+
+ /**
* Returns an instance of {@code MetalButtonUI}.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java 2020-08-15 17:34:41.649434200 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java 2020-08-15 17:34:40.163066600 +0530
@@ -50,6 +50,11 @@
public class MetalCheckBoxIcon implements Icon, UIResource, Serializable {
/**
+ * Constructs a {@code MetalCheckBoxIcon}.
+ */
+ public MetalCheckBoxIcon() {}
+
+ /**
* Returns the size of the control.
*
* @return the size of the control
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java 2020-08-15 17:34:50.449596600 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java 2020-08-15 17:34:48.972379200 +0530
@@ -69,6 +69,11 @@
// ********************************
/**
+ * Constructs a {@code MetalCheckBoxUI}.
+ */
+ public MetalCheckBoxUI() {}
+
+ /**
* Returns an instance of {@code MetalCheckBoxUI}.
*
* @param b a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java 2020-08-15 17:34:59.301984100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java 2020-08-15 17:34:57.837906900 +0530
@@ -140,5 +140,9 @@
@SuppressWarnings("serial") // Same-version serialization only
public static class UIResource extends MetalComboBoxEditor
implements javax.swing.plaf.UIResource {
+ /**
+ * Constructs a {@code UIResource}.
+ */
+ public UIResource() {}
}
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxIcon.java 2020-08-15 17:35:08.256668100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxIcon.java 2020-08-15 17:35:06.744908600 +0530
@@ -44,6 +44,11 @@
public class MetalComboBoxIcon implements Icon, Serializable {
/**
+ * Constructs a {@code MetalComboBoxIcon}.
+ */
+ public MetalComboBoxIcon() {}
+
+ /**
* Paints the horizontal bars for the
*/
public void paintIcon(Component c, Graphics g, int x, int y){
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java 2020-08-15 17:35:17.228508700 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java 2020-08-15 17:35:15.631214600 +0530
@@ -55,6 +55,11 @@
public class MetalComboBoxUI extends BasicComboBoxUI {
/**
+ * Constructs a {@code MetalComboBoxUI}.
+ */
+ public MetalComboBoxUI() {}
+
+ /**
* Constructs an instance of {@code MetalComboBoxUI}.
*
* @param c a component
@@ -210,6 +215,11 @@
* Instantiate it only within subclasses of {@code MetalComboBoxUI}.
*/
public class MetalPropertyChangeListener extends BasicComboBoxUI.PropertyChangeHandler {
+ /**
+ * Constructs a {@code MetalPropertyChangeListener}.
+ */
+ public MetalPropertyChangeListener() {}
+
public void propertyChange(PropertyChangeEvent e) {
super.propertyChange( e );
String propertyName = e.getPropertyName();
@@ -255,6 +265,11 @@
* Instantiate it only within subclasses of {@code MetalComboBoxUI}.
*/
public class MetalComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
+ /**
+ * Constructs a {@code MetalComboBoxLayoutManager}.
+ */
+ public MetalComboBoxLayoutManager() {}
+
public void layoutContainer( Container parent ) {
layoutComboBox( parent, this );
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java 2020-08-15 17:35:26.006977000 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java 2020-08-15 17:35:24.499208100 +0530
@@ -1129,6 +1129,11 @@
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public class FilterComboBoxRenderer extends DefaultListCellRenderer {
+ /**
+ * Constructs a {@code FilterComboBoxRenderer}.
+ */
+ public FilterComboBoxRenderer() {}
+
public Component getListCellRendererComponent(JList<?> list,
Object value, int index, boolean isSelected,
boolean cellHasFocus) {
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java 2020-08-15 17:35:35.668564800 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java 2020-08-15 17:35:34.150609100 +0530
@@ -102,6 +102,11 @@
*/
public static final boolean LIGHT = true;
+ /**
+ * Constructs a {@code MetalIconFactory}.
+ */
+ public MetalIconFactory() {}
+
// Accessor functions for Icons. Does the caching work.
/**
* Returns the instance of {@code FileChooserDetailViewIcon}.
@@ -645,6 +650,11 @@
public static class PaletteCloseIcon implements Icon, UIResource, Serializable{
int iconSize = 7;
+ /**
+ * Constructs a {@code PaletteCloseIcon}.
+ */
+ public PaletteCloseIcon() {}
+
public void paintIcon(Component c, Graphics g, int x, int y) {
JButton parentButton = (JButton)c;
ButtonModel buttonModel = parentButton.getModel();
@@ -1648,6 +1658,11 @@
ImageCacher imageCacher;
+ /**
+ * Constructs a {@code FolderIcon16}.
+ */
+ public FolderIcon16() {}
+
public void paintIcon(Component c, Graphics g, int x, int y) {
GraphicsConfiguration gc = c.getGraphicsConfiguration();
if (imageCacher == null) {
@@ -1739,6 +1754,11 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class TreeFolderIcon extends FolderIcon16 {
+ /**
+ * Constructs a {@code TreeFolderIcon}.
+ */
+ public TreeFolderIcon() {}
+
public int getShift() { return -1; }
public int getAdditionalHeight() { return 2; }
}
@@ -1762,6 +1782,11 @@
ImageCacher imageCacher;
+ /**
+ * Constructs a {@code FileIcon16}.
+ */
+ public FileIcon16() {}
+
public void paintIcon(Component c, Graphics g, int x, int y) {
GraphicsConfiguration gc = c.getGraphicsConfiguration();
if (imageCacher == null) {
@@ -1839,6 +1864,10 @@
* The class represents a tree leaf icon.
*/
public static class TreeLeafIcon extends FileIcon16 {
+ /**
+ * Constructs a {@code TreeLeafIcon}.
+ */
+ public TreeLeafIcon() {}
public int getShift() { return 2; }
public int getAdditionalHeight() { return 4; }
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java 2020-08-15 17:35:44.843324300 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java 2020-08-15 17:35:43.292334200 +0530
@@ -57,6 +57,11 @@
private static final Object METAL_LABEL_UI_KEY = new Object();
/**
+ * Constructs a {@code MetalLabelUI}.
+ */
+ public MetalLabelUI() {}
+
+ /**
* Returns an instance of {@code MetalLabelUI}.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java 2020-08-15 17:35:53.820359300 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java 2020-08-15 17:35:52.323129800 +0530
@@ -108,6 +108,10 @@
*/
private static boolean useSystemFonts;
+ /**
+ * Constructs a {@code MetalLookAndFeel}.
+ */
+ public MetalLookAndFeel() {}
/**
* Returns true if running on Windows.
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalMenuBarUI.java 2020-08-15 17:36:03.317352900 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalMenuBarUI.java 2020-08-15 17:36:01.826517200 +0530
@@ -40,6 +40,11 @@
*/
public class MetalMenuBarUI extends BasicMenuBarUI {
/**
+ * Constructs a {@code MetalMenuBarUI}.
+ */
+ public MetalMenuBarUI() {}
+
+ /**
* Creates the <code>ComponentUI</code> implementation for the passed
* in component.
*
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java 2020-08-15 17:36:12.470442100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java 2020-08-15 17:36:10.821631500 +0530
@@ -44,6 +44,11 @@
public class MetalPopupMenuSeparatorUI extends MetalSeparatorUI
{
/**
+ * Constructs a {@code MetalPopupMenuSeparatorUI}.
+ */
+ public MetalPopupMenuSeparatorUI() {}
+
+ /**
* Constructs a new {@code MetalPopupMenuSeparatorUI} instance.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java 2020-08-15 17:36:21.333259100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java 2020-08-15 17:36:19.843836700 +0530
@@ -51,6 +51,11 @@
private Rectangle box;
/**
+ * Constructs a {@code MetalProgressBarUI}.
+ */
+ public MetalProgressBarUI() {}
+
+ /**
* Constructs an instance of {@code MetalProgressBarUI}.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java 2020-08-15 17:36:30.364800400 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java 2020-08-15 17:36:28.781338700 +0530
@@ -80,6 +80,11 @@
// ********************************
/**
+ * Constructs a {@code MetalRadioButtonUI}.
+ */
+ public MetalRadioButtonUI() {}
+
+ /**
* Returns an instance of {@code MetalRadioButtonUI}.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java 2020-08-15 17:36:40.315827200 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java 2020-08-15 17:36:38.171396100 +0530
@@ -124,6 +124,11 @@
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
/**
+ * Constructs a {@code MetalRootPaneUI}.
+ */
+ public MetalRootPaneUI() {}
+
+ /**
* Creates a UI for a <code>JRootPane</code>.
*
* @param c the JRootPane the RootPaneUI will be created for
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java 2020-08-15 17:36:51.566166700 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java 2020-08-15 17:36:49.587804300 +0530
@@ -90,6 +90,11 @@
protected boolean isFreeStanding = true;
/**
+ * Constructs a {@code MetalScrollBarUI}.
+ */
+ public MetalScrollBarUI() {}
+
+ /**
* Constructs a new {@code MetalScrollBarUI} instance.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java 2020-08-15 17:37:02.857591900 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java 2020-08-15 17:37:00.938565100 +0530
@@ -57,6 +57,11 @@
private PropertyChangeListener scrollBarSwapListener;
/**
+ * Constructs a {@code MetalScrollPaneUI}.
+ */
+ public MetalScrollPaneUI() {}
+
+ /**
* Constructs a new {@code MetalScrollPaneUI}.
*
* @param x a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java 2020-08-15 17:37:11.931248000 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java 2020-08-15 17:37:10.429122700 +0530
@@ -54,6 +54,11 @@
public class MetalSeparatorUI extends BasicSeparatorUI
{
/**
+ * Constructs a {@code MetalSeparatorUI}.
+ */
+ public MetalSeparatorUI() {}
+
+ /**
* Constructs a new {@code MetalSeparatorUI} instance.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java 2020-08-15 17:37:20.964121400 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java 2020-08-15 17:37:19.450296900 +0530
@@ -46,7 +46,10 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalSplitPaneUI extends BasicSplitPaneUI
{
-
+ /**
+ * Constructs a {@code MetalSplitPaneUI}.
+ */
+ public MetalSplitPaneUI() {}
/**
* Creates a new {@code MetalSplitPaneUI} instance
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java 2020-08-15 17:37:30.298155100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java 2020-08-15 17:37:28.710332400 +0530
@@ -81,6 +81,11 @@
private Color oceanSelectedBorderColor;
/**
+ * Constructs a {@code MetalTabbedPaneUI}.
+ */
+ public MetalTabbedPaneUI() {}
+
+ /**
* Constructs {@code MetalTabbedPaneUI}.
*
* @param x a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java 2020-08-15 17:37:39.414843100 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java 2020-08-15 17:37:37.691645200 +0530
@@ -51,6 +51,11 @@
public class MetalTextFieldUI extends BasicTextFieldUI {
/**
+ * Constructs a {@code MetalTextFieldUI}.
+ */
+ public MetalTextFieldUI() {}
+
+ /**
* Constructs {@code MetalTextFieldUI}.
*
* @param c a component
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTheme.java 2020-08-15 17:37:48.341319500 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTheme.java 2020-08-15 17:37:46.819658900 +0530
@@ -77,6 +77,11 @@
private static ColorUIResource black = new ColorUIResource( 0, 0, 0 );
/**
+ * Constructor for subclasses to call.
+ */
+ protected MetalTheme() {}
+
+ /**
* Returns the name of this theme.
*
* @return the name of this theme
--- old/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java 2020-08-15 17:37:58.119098300 +0530
+++ new/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java 2020-08-15 17:37:56.191270800 +0530
@@ -82,6 +82,11 @@
// ********************************
/**
+ * Constructs a {@code MetalToggleButtonUI}.
+ */
+ public MetalToggleButtonUI() {}
+
+ /**
* Constructs the {@code MetalToogleButtonUI}.
*
* @param b a component