8250852: Address reliance on default constructors in the javax.swing.plaf.basic APIs

Reviewed-by: serb, aivanov
This commit is contained in:
Prasanta Sadhukhan 2020-08-19 11:49:54 +05:30
parent d8d3cc3ab6
commit e6a0c6cf4d
20 changed files with 199 additions and 0 deletions

View File

@ -71,6 +71,11 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
private Rectangle paintIconR = new Rectangle();
private Rectangle paintTextR = new Rectangle();
/**
* Constructs a {@code BasicLabelUI}.
*/
public BasicLabelUI() {}
static void loadActionMap(LazyActionMap map) {
map.put(new Actions(Actions.PRESS));
map.put(new Actions(Actions.RELEASE));

View File

@ -199,6 +199,11 @@ public class BasicListUI extends ListUI
private static final int DROP_LINE_THICKNESS = 2;
/**
* Constructs a {@code BasicListUI}.
*/
public BasicListUI() {}
static void loadActionMap(LazyActionMap map) {
map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN));
map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN_EXTEND));
@ -1577,6 +1582,11 @@ public class BasicListUI extends ListUI
@SuppressWarnings("serial") // Same-version serialization only
public class MouseInputHandler implements MouseInputListener
{
/**
* Constructs a {@code MouseInputHandler}.
*/
public MouseInputHandler() {}
public void mouseClicked(MouseEvent e) {
getHandler().mouseClicked(e);
}
@ -1640,6 +1650,11 @@ public class BasicListUI extends ListUI
*/
public class FocusHandler implements FocusListener
{
/**
* Constructs a {@code FocusHandler}.
*/
public FocusHandler() {}
/**
* Repaints focused cells.
*/
@ -1691,6 +1706,11 @@ public class BasicListUI extends ListUI
@SuppressWarnings("serial") // Same-version serialization only
public class ListSelectionHandler implements ListSelectionListener
{
/**
* Constructs a {@code ListSelectionHandler}.
*/
public ListSelectionHandler() {}
public void valueChanged(ListSelectionEvent e)
{
getHandler().valueChanged(e);
@ -1752,6 +1772,11 @@ public class BasicListUI extends ListUI
@SuppressWarnings("serial") // Same-version serialization only
public class ListDataHandler implements ListDataListener
{
/**
* Constructs a {@code ListDataHandler}.
*/
public ListDataHandler() {}
public void intervalAdded(ListDataEvent e) {
getHandler().intervalAdded(e);
}
@ -1820,6 +1845,11 @@ public class BasicListUI extends ListUI
@SuppressWarnings("serial") // Same-version serialization only
public class PropertyChangeHandler implements PropertyChangeListener
{
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}
public void propertyChange(PropertyChangeEvent e)
{
getHandler().propertyChange(e);

View File

@ -127,6 +127,11 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
*/
private PropertyChangeListener disposer = null;
/**
* Constructor for subclasses to call.
*/
protected BasicLookAndFeel() {}
/**
* Returns the look and feel defaults. The returned {@code UIDefaults}
* is populated by invoking, in order, {@code initClassDefaults},

View File

@ -71,6 +71,11 @@ public class BasicMenuBarUI extends MenuBarUI {
protected ChangeListener changeListener;
private Handler handler;
/**
* Constructs a {@code BasicMenuBarUI}.
*/
public BasicMenuBarUI() {}
/**
* Returns a new instance of {@code BasicMenuBarUI}.
*

View File

@ -131,6 +131,11 @@ public class BasicMenuItemUI extends MenuItemUI
private static final boolean VERBOSE = false; // show reuse hits/misses
private static final boolean DEBUG = false; // show bad params, misc.
/**
* Constructs a {@code BasicMenuItemUI}.
*/
public BasicMenuItemUI() {}
static void loadActionMap(LazyActionMap map) {
// NOTE: BasicMenuUI also calls into this method.
map.put(new Actions(Actions.CLICK));

View File

@ -70,6 +70,11 @@ public class BasicMenuUI extends BasicMenuItemUI
private static boolean crossMenuMnemonic = true;
/**
* Constructs a {@code BasicMenuUI}.
*/
public BasicMenuUI() {}
/**
* Constructs a new instance of {@code BasicMenuUI}.
*

View File

@ -127,6 +127,11 @@ public class BasicOptionPaneUI extends OptionPaneUI {
}
}
/**
* Constructs a {@code BasicOptionPaneUI}.
*/
public BasicOptionPaneUI() {}
static void loadActionMap(LazyActionMap map) {
map.put(new Actions(Actions.CLOSE));
BasicLookAndFeel.installAudioActionMap(map);
@ -1257,6 +1262,11 @@ public class BasicOptionPaneUI extends OptionPaneUI {
* Instantiate it only within subclasses of {@code BasicOptionPaneUI}.
*/
public class PropertyChangeHandler implements PropertyChangeListener {
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}
/**
* If the source of the PropertyChangeEvent <code>e</code> equals the
* optionPane and is one of the ICON_PROPERTY, MESSAGE_PROPERTY,

View File

@ -43,6 +43,11 @@ public class BasicPanelUI extends PanelUI {
// Shared UI object
private static PanelUI panelUI;
/**
* Constructs a {@code BasicPanelUI}.
*/
public BasicPanelUI() {}
/**
* Returns an instance of {@code BasicPanelUI}.
*

View File

@ -42,6 +42,11 @@ import javax.swing.plaf.*;
*/
public class BasicPasswordFieldUI extends BasicTextFieldUI {
/**
* Constructs a {@code BasicPasswordFieldUI}.
*/
public BasicPasswordFieldUI() {}
/**
* Creates a UI for a JPasswordField.
*

View File

@ -42,6 +42,11 @@ import javax.swing.plaf.ComponentUI;
public class BasicPopupMenuSeparatorUI extends BasicSeparatorUI
{
/**
* Constructs a {@code BasicPopupMenuSeparatorUI}.
*/
public BasicPopupMenuSeparatorUI() {}
/**
* Returns a new instance of {@code BasicPopupMenuSeparatorUI}.
*

View File

@ -133,6 +133,11 @@ public class BasicProgressBarUI extends ProgressBarUI {
private int maxPosition = 0; //maximum X (horiz) or Y box location
/**
* Constructs a {@code BasicProgressBarUI}.
*/
public BasicProgressBarUI() {}
/**
* Returns a new instance of {@code BasicProgressBarUI}.
*
@ -1288,6 +1293,11 @@ public class BasicProgressBarUI extends ProgressBarUI {
* Instantiate it only within subclasses of {@code BasicProgressBarUI}.
*/
public class ChangeHandler implements ChangeListener {
/**
* Constructs a {@code ChangeHandler}.
*/
public ChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this

View File

@ -39,6 +39,11 @@ import javax.swing.border.*;
*/
public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
{
/**
* Constructs a {@code BasicRadioButtonMenuItemUI}.
*/
public BasicRadioButtonMenuItemUI() {}
/**
* Returns a new instance of {@code BasicRadioButtonMenuItemUI}.
*

View File

@ -61,6 +61,11 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
// Create PLAF
// ********************************
/**
* Constructs a {@code BasicRadioButtonUI}.
*/
public BasicRadioButtonUI() {}
/**
* Returns an instance of {@code BasicRadioButtonUI}.
*

View File

@ -48,6 +48,11 @@ public class BasicRootPaneUI extends RootPaneUI implements
PropertyChangeListener {
private static RootPaneUI rootPaneUI = new BasicRootPaneUI();
/**
* Constructs a {@code BasicRootPaneUI}.
*/
public BasicRootPaneUI() {}
/**
* Returns a new instance of {@code BasicRootPaneUI}.
*

View File

@ -163,6 +163,11 @@ public class BasicScrollBarUI
*/
protected int decrGap;
/**
* Constructs a {@code BasicScrollBarUI}.
*/
public BasicScrollBarUI() {}
static void loadActionMap(LazyActionMap map) {
map.put(new Actions(Actions.POSITIVE_UNIT_INCREMENT));
map.put(new Actions(Actions.POSITIVE_BLOCK_INCREMENT));
@ -1645,6 +1650,11 @@ public class BasicScrollBarUI
/** Property change handler */
public class PropertyChangeHandler implements PropertyChangeListener
{
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this

View File

@ -98,6 +98,11 @@ public class BasicScrollPaneUI
*/
private boolean setValueCalled = false;
/**
* Constructs a {@code BasicScrollPaneUI}.
*/
public BasicScrollPaneUI() {}
/**
* Returns a new instance of {@code BasicScrollPaneUI}.
*
@ -494,6 +499,10 @@ public class BasicScrollPaneUI
*/
public class ViewportChangeHandler implements ChangeListener
{
/**
* Constructs a {@code ViewportChangeHandler}.
*/
public ViewportChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
@ -520,6 +529,10 @@ public class BasicScrollPaneUI
*/
public class HSBChangeListener implements ChangeListener
{
/**
* Constructs a {@code HSBChangeListener}.
*/
public HSBChangeListener() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
@ -555,6 +568,10 @@ public class BasicScrollPaneUI
*/
public class VSBChangeListener implements ChangeListener
{
/**
* Constructs a {@code VSBChangeListener}.
*/
public VSBChangeListener() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
@ -751,6 +768,10 @@ public class BasicScrollPaneUI
*/
public class PropertyChangeHandler implements PropertyChangeListener
{
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add

View File

@ -55,6 +55,11 @@ public class BasicSeparatorUI extends SeparatorUI
*/
protected Color highlight;
/**
* Constructs a {@code BasicSeparatorUI}.
*/
public BasicSeparatorUI() {}
/**
* Returns a new instance of {@code BasicSeparatorUI}.
*

View File

@ -116,6 +116,11 @@ public class BasicSliderUI extends SliderUI{
*/
private boolean sameLabelBaselines;
/**
* Constructs a {@code BasicSliderUI}.
*/
public BasicSliderUI() {}
/**
* Returns the shadow color.
* @return the shadow color
@ -918,6 +923,11 @@ public class BasicSliderUI extends SliderUI{
* A property change handler.
*/
public class PropertyChangeHandler implements PropertyChangeListener {
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
@ -1863,6 +1873,11 @@ public class BasicSliderUI extends SliderUI{
* Instantiate it only within subclasses of <code>Foo</code>.
*/
public class ChangeHandler implements ChangeListener {
/**
* Constructs a {@code ChangeHandler}.
*/
public ChangeHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
@ -1889,6 +1904,11 @@ public class BasicSliderUI extends SliderUI{
/** Current mouse y. */
protected transient int currentMouseY;
/**
* Constructs a {@code TrackListener}.
*/
public TrackListener() {}
/**
* {@inheritDoc}
*/
@ -2200,6 +2220,11 @@ public class BasicSliderUI extends SliderUI{
* Instantiate it only within subclasses of <code>Foo</code>.
*/
public class ComponentHandler extends ComponentAdapter {
/**
* Constructs a {@code ComponentHandler}.
*/
public ComponentHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
@ -2216,6 +2241,11 @@ public class BasicSliderUI extends SliderUI{
* Instantiate it only within subclasses of <code>Foo</code>.
*/
public class FocusHandler implements FocusListener {
/**
* Constructs a {@code FocusHandler}.
*/
public FocusHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this

View File

@ -80,6 +80,10 @@ public class BasicSpinnerUI extends SpinnerUI
*/
private static final Dimension zeroSize = new Dimension(0, 0);
/**
* Constructs a {@code BasicSpinnerUI}.
*/
public BasicSpinnerUI() {}
/**
* Returns a new instance of BasicSpinnerUI. SpinnerListUI

View File

@ -286,6 +286,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** If true, setDividerLocation does nothing. */
boolean ignoreDividerLocationChange;
/**
* Constructs a {@code BasicSplitPaneUI}.
*/
public BasicSplitPaneUI() {}
/**
* Creates a new instance of {@code BasicSplitPaneUI}.
@ -734,6 +738,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public class FocusHandler extends FocusAdapter
{
/**
* Constructs a {@code FocusHandler}.
*/
public FocusHandler() {}
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
@ -774,6 +783,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public class KeyboardDownRightHandler implements ActionListener
{
/**
* Constructs a {@code KeyboardDownRightHandler}.
*/
public KeyboardDownRightHandler() {}
public void actionPerformed(ActionEvent ev) {
if (dividerKeyboardResize) {
splitPane.setDividerLocation(getDividerLocation(splitPane) +
@ -792,6 +806,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public class KeyboardHomeHandler implements ActionListener
{
/**
* Constructs a {@code KeyboardHomeHandler}.
*/
public KeyboardHomeHandler() {}
public void actionPerformed(ActionEvent ev) {
if (dividerKeyboardResize) {
splitPane.setDividerLocation(0);
@ -809,6 +828,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public class KeyboardEndHandler implements ActionListener
{
/**
* Constructs a {@code KeyboardEndHandler}.
*/
public KeyboardEndHandler() {}
public void actionPerformed(ActionEvent ev) {
if (dividerKeyboardResize) {
Insets insets = splitPane.getInsets();