Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8250850: Address reliance on default constructors in the javax.swing.…
…plaf.metal APIs

Reviewed-by: serb
  • Loading branch information
prsadhuk committed Aug 26, 2020
1 parent 1a24996 commit e0763c59072cb0a29c5a42bd1bd221410b2355f9
Showing with 221 additions and 1 deletion.
  1. +75 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
  2. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java
  3. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java
  4. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java
  5. +4 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java
  6. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxIcon.java
  7. +15 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java
  8. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java
  9. +29 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
  10. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java
  11. +4 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
  12. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalMenuBarUI.java
  13. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
  14. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java
  15. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java
  16. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java
  17. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java
  18. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java
  19. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java
  20. +4 −1 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java
  21. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
  22. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java
  23. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTheme.java
  24. +5 −0 src/java.desktop/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java
@@ -57,11 +57,21 @@ public class MetalBorders {
static Object NO_BUTTON_ROLLOVER =
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 @@ public static class ButtonBorder extends AbstractBorder implements UIResource {
*/
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 Insets getBorderInsets(Component c, Insets newInsets) {
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 @@ protected Color getActiveBackground() {
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 Insets getBorderInsets(Component c, Insets newInsets) {
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 @@ public static class MenuBarBorder extends AbstractBorder implements UIResource {
*/
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 @@ public static class MenuItemBorder extends AbstractBorder implements UIResource
*/
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 @@ public static class PopupMenuBorder extends AbstractBorder implements UIResource
*/
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 @@ public Insets getBorderInsets(Component c, Insets newInsets) {
@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 @@ public static class ToolBarBorder extends AbstractBorder implements UIResource,
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 @@ public static Border getTextFieldBorder() {
@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 @@ public void paintBorder(Component c, Graphics g, int x, int y,
*/
@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 @@ public static Border getToggleButtonBorder() {
*/
@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();
@@ -1000,6 +1070,11 @@ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class TableHeaderBorder extends javax.swing.border.AbstractBorder {

/**
* Constructs a {@code TableHeaderBorder}.
*/
public TableHeaderBorder() {}

/**
* The border insets.
*/
@@ -76,6 +76,11 @@ public class MetalButtonUI extends BasicButtonUI {
// Create PLAF
// ********************************

/**
* Constructs a {@code MetalButtonUI}.
*/
public MetalButtonUI() {}

/**
* Returns an instance of {@code MetalButtonUI}.
*
@@ -49,6 +49,11 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalCheckBoxIcon implements Icon, UIResource, Serializable {

/**
* Constructs a {@code MetalCheckBoxIcon}.
*/
public MetalCheckBoxIcon() {}

/**
* Returns the size of the control.
*
@@ -68,6 +68,11 @@ public class MetalCheckBoxUI extends MetalRadioButtonUI {
// Create PlAF
// ********************************

/**
* Constructs a {@code MetalCheckBoxUI}.
*/
public MetalCheckBoxUI() {}

/**
* Returns an instance of {@code MetalCheckBoxUI}.
*
@@ -140,5 +140,9 @@ public Insets getBorderInsets(Component c, Insets insets) {
@SuppressWarnings("serial") // Same-version serialization only
public static class UIResource extends MetalComboBoxEditor
implements javax.swing.plaf.UIResource {
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}
}
@@ -43,6 +43,11 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalComboBoxIcon implements Icon, Serializable {

/**
* Constructs a {@code MetalComboBoxIcon}.
*/
public MetalComboBoxIcon() {}

/**
* Paints the horizontal bars for the
*/
@@ -54,6 +54,11 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalComboBoxUI extends BasicComboBoxUI {

/**
* Constructs a {@code MetalComboBoxUI}.
*/
public MetalComboBoxUI() {}

/**
* Constructs an instance of {@code MetalComboBoxUI}.
*
@@ -210,6 +215,11 @@ public PropertyChangeListener createPropertyChangeListener() {
* 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 @@ protected LayoutManager createLayoutManager() {
* 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 );
}
@@ -1129,6 +1129,11 @@ protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
*/
@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) {
@@ -102,6 +102,11 @@ public class MetalIconFactory implements Serializable {
*/
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 int getIconHeight() {
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 @@ public static class FolderIcon16 implements Icon, Serializable {

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 @@ private void paintMe(Component c, Graphics g) {
*/
@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 @@ public static class FileIcon16 implements Icon, Serializable {

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 @@ private void paintMe(Component c, Graphics g) {
* 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; }
}
@@ -56,6 +56,11 @@ public class MetalLabelUI extends BasicLabelUI

private static final Object METAL_LABEL_UI_KEY = new Object();

/**
* Constructs a {@code MetalLabelUI}.
*/
public MetalLabelUI() {}

/**
* Returns an instance of {@code MetalLabelUI}.
*
@@ -108,6 +108,10 @@ public class MetalLookAndFeel extends BasicLookAndFeel
*/
private static boolean useSystemFonts;

/**
* Constructs a {@code MetalLookAndFeel}.
*/
public MetalLookAndFeel() {}

/**
* Returns true if running on Windows.
@@ -39,6 +39,11 @@
* @since 1.5
*/
public class MetalMenuBarUI extends BasicMenuBarUI {
/**
* Constructs a {@code MetalMenuBarUI}.
*/
public MetalMenuBarUI() {}

/**
* Creates the <code>ComponentUI</code> implementation for the passed
* in component.

0 comments on commit e0763c5

Please sign in to comment.