Skip to content

Commit

Permalink
8252722: More Swing plaf APIs that rely on default constructors
Browse files Browse the repository at this point in the history
Reviewed-by: prr
  • Loading branch information
prsadhuk committed Sep 24, 2020
1 parent 3495c19 commit 527a309
Show file tree
Hide file tree
Showing 36 changed files with 468 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@

public class BasicBorders {

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

/**
* Returns a border instance for a {@code JButton}.
*
Expand Down Expand Up @@ -473,6 +478,11 @@ public Insets getBorderInsets(Component c, Insets insets) {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class MarginBorder extends AbstractBorder implements UIResource {
/**
* Constructs a {@code MarginBorder}.
*/
public MarginBorder() {}

public Insets getBorderInsets(Component c, Insets insets) {
Insets margin = null;
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public class BasicButtonUI extends ButtonUI{
// ********************************
// Create PLAF
// ********************************
/**
* Constructs a {@code BasicButtonUI}.
*/
public BasicButtonUI() {}

/**
* Returns an instance of {@code BasicButtonUI}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
*/
public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI {

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

/**
* Constructs a new instance of {@code BasicCheckBoxMenuItemUI}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI {
// Create PLAF
// ********************************

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

/**
* Returns an instance of {@code BasicCheckBoxUI}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public class BasicColorChooserUI extends ColorChooserUI
protected PropertyChangeListener propertyChangeListener;
private Handler handler;

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

/**
* Returns a new instance of {@code BasicColorChooserUI}.
*
Expand Down Expand Up @@ -383,6 +388,11 @@ else if (prop == "componentOrientation") {
* Instantiate it only within subclasses of {@code BasicColorChooserUI}.
*/
public class PropertyHandler implements PropertyChangeListener {
/**
* Constructs a {@code PropertyHandler}.
*/
public PropertyHandler() {}

public void propertyChange(PropertyChangeEvent e) {
getHandler().propertyChange(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,9 @@ public void setBorder(Border b) {
@SuppressWarnings("serial") // Same-version serialization only
public static class UIResource extends BasicComboBoxEditor
implements javax.swing.plaf.UIResource {
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,9 @@ public Component getListCellRendererComponent(JList<?> list,
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class UIResource extends BasicComboBoxRenderer implements javax.swing.plaf.UIResource {
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ public class BasicComboBoxUI extends ComboBoxUI {
*/
protected Insets padding;

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

// Used for calculating the default size.
private static ListCellRenderer<Object> getDefaultListCellRenderer() {
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -592,6 +597,11 @@ private Handler getHandler() {
* <code>BasicComboBoxUI</code>.
*/
public class KeyHandler extends KeyAdapter {
/**
* Constructs a {@code KeyHandler}.
*/
public KeyHandler() {}

@Override
public void keyPressed( KeyEvent e ) {
getHandler().keyPressed(e);
Expand All @@ -607,6 +617,11 @@ public void keyPressed( KeyEvent e ) {
* <code>BasicComboBoxUI</code>.
*/
public class FocusHandler implements FocusListener {
/**
* Constructs a {@code FocusHandler}.
*/
public FocusHandler() {}

public void focusGained( FocusEvent e ) {
getHandler().focusGained(e);
}
Expand All @@ -627,6 +642,11 @@ public void focusLost( FocusEvent e ) {
* @see #createListDataListener
*/
public class ListDataHandler implements ListDataListener {
/**
* Constructs a {@code ListDataHandler}.
*/
public ListDataHandler() {}

public void contentsChanged( ListDataEvent e ) {
getHandler().contentsChanged(e);
}
Expand All @@ -651,6 +671,11 @@ public void intervalRemoved( ListDataEvent e ) {
* @see #createItemListener
*/
public class ItemHandler implements ItemListener {
/**
* Constructs a {@code ItemHandler}.
*/
public ItemHandler() {}

// This class used to implement behavior which is now redundant.
public void itemStateChanged(ItemEvent e) {}
}
Expand All @@ -670,6 +695,11 @@ public void itemStateChanged(ItemEvent e) {}
* @see #createPropertyChangeListener
*/
public class PropertyChangeHandler implements PropertyChangeListener {
/**
* Constructs a {@code PropertyChangeHandler}.
*/
public PropertyChangeHandler() {}

public void propertyChange(PropertyChangeEvent e) {
getHandler().propertyChange(e);
}
Expand Down Expand Up @@ -697,6 +727,11 @@ private void updateToolTipTextForChildren() {
* <code>BasicComboBoxUI</code>.
*/
public class ComboBoxLayoutManager implements LayoutManager {
/**
* Constructs a {@code ComboBoxLayoutManager}.
*/
public ComboBoxLayoutManager() {}

public void addLayoutComponent(String name, Component comp) {}

public void removeLayoutComponent(Component comp) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ public void actionPerformed(ActionEvent e){
* @see BasicComboPopup#createMouseListener
*/
protected class InvocationMouseHandler extends MouseAdapter {
/**
* Constructs an {@code InvocationMouseHandler}.
*/
protected InvocationMouseHandler() {}

/**
* Responds to mouse-pressed events on the combo box.
*
Expand All @@ -758,6 +763,11 @@ public void mouseReleased( MouseEvent e ) {
* list if it is dragging over the list.
*/
protected class InvocationMouseMotionHandler extends MouseMotionAdapter {
/**
* Constructs an {@code InvocationMouseMotionHandler}.
*/
protected InvocationMouseMotionHandler() {}

public void mouseDragged( MouseEvent e ) {
getHandler().mouseDragged(e);
}
Expand All @@ -771,6 +781,10 @@ public void mouseDragged( MouseEvent e ) {
* BasicComboBoxUI ActionMap/InputMap methods.
*/
public class InvocationKeyHandler extends KeyAdapter {
/**
* Constructs an {@code InvocationKeyHandler}.
*/
public InvocationKeyHandler() {}
public void keyReleased( KeyEvent e ) {}
}

Expand All @@ -780,6 +794,10 @@ public void keyReleased( KeyEvent e ) {}
* override.
*/
protected class ListSelectionHandler implements ListSelectionListener {
/**
* Constructs a {@code ListSelectionHandler}.
*/
protected ListSelectionHandler() {}
public void valueChanged( ListSelectionEvent e ) {}
}

Expand All @@ -793,6 +811,10 @@ public void valueChanged( ListSelectionEvent e ) {}
* @see #createItemListener
*/
public class ListDataHandler implements ListDataListener {
/**
* Constructs a {@code ListDataHandler}.
*/
public ListDataHandler() {}
public void contentsChanged( ListDataEvent e ) {}

public void intervalAdded( ListDataEvent e ) {
Expand All @@ -806,6 +828,10 @@ public void intervalRemoved( ListDataEvent e ) {
* This listener hides the popup when the mouse is released in the list.
*/
protected class ListMouseHandler extends MouseAdapter {
/**
* Constructs a {@code ListMouseHandler}.
*/
protected ListMouseHandler() {}
public void mousePressed( MouseEvent e ) {
}
public void mouseReleased(MouseEvent anEvent) {
Expand All @@ -818,6 +844,11 @@ public void mouseReleased(MouseEvent anEvent) {
* The selection change is not committed to the model, this is for user feedback only.
*/
protected class ListMouseMotionHandler extends MouseMotionAdapter {
/**
* Constructs a {@code ListMouseMotionHandler}.
*/
protected ListMouseMotionHandler() {}

public void mouseMoved( MouseEvent anEvent ) {
getHandler().mouseMoved(anEvent);
}
Expand All @@ -828,6 +859,10 @@ public void mouseMoved( MouseEvent anEvent ) {
* combo box.
*/
protected class ItemHandler implements ItemListener {
/**
* Constructs an {@code ItemHandler}.
*/
protected ItemHandler() {}
public void itemStateChanged( ItemEvent e ) {
getHandler().itemStateChanged(e);
}
Expand All @@ -844,6 +879,10 @@ public void itemStateChanged( ItemEvent e ) {
* @see #createPropertyChangeListener
*/
protected class PropertyChangeHandler implements PropertyChangeListener {
/**
* Constructs a {@code PropertyChangeHandler}.
*/
protected PropertyChangeHandler() {}
public void propertyChange( PropertyChangeEvent e ) {
getHandler().propertyChange(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public class MouseInputHandler extends MouseInputAdapter
int __x, __y;
Rectangle startingBounds;

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

public void mouseReleased(MouseEvent e) {
_x = 0;
_y = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ public boolean accept(Object sender) {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class OpenAction extends AbstractAction {
/**
* Constructs an {@code OpenAction}.
*/
protected OpenAction() {}
public void actionPerformed(ActionEvent evt) {
JDesktopPane dp = (JDesktopPane)evt.getSource();
SHARED_ACTION.setState(dp, Actions.RESTORE);
Expand All @@ -693,6 +697,10 @@ public boolean isEnabled() {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class CloseAction extends AbstractAction {
/**
* Constructs a {@code CloseAction}.
*/
protected CloseAction() {}
public void actionPerformed(ActionEvent evt) {
JDesktopPane dp = (JDesktopPane)evt.getSource();
SHARED_ACTION.setState(dp, Actions.CLOSE);
Expand All @@ -712,6 +720,10 @@ public boolean isEnabled() {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class MinimizeAction extends AbstractAction {
/**
* Constructs a {@code MinimizeAction}.
*/
protected MinimizeAction() {}
public void actionPerformed(ActionEvent evt) {
JDesktopPane dp = (JDesktopPane)evt.getSource();
SHARED_ACTION.setState(dp, Actions.MINIMIZE);
Expand All @@ -731,6 +743,10 @@ public boolean isEnabled() {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class MaximizeAction extends AbstractAction {
/**
* Constructs a {@code MaximizeAction}.
*/
protected MaximizeAction() {}
public void actionPerformed(ActionEvent evt) {
JDesktopPane dp = (JDesktopPane)evt.getSource();
SHARED_ACTION.setState(dp, Actions.MAXIMIZE);
Expand All @@ -750,6 +766,10 @@ public boolean isEnabled() {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class NavigateAction extends AbstractAction {
/**
* Constructs a {@code NavigateAction}.
*/
protected NavigateAction() {}
public void actionPerformed(ActionEvent evt) {
JDesktopPane dp = (JDesktopPane)evt.getSource();
dp.selectFrame(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ protected class SelectionListener implements ListSelectionListener {
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.

/**
* Constructs a {@code SelectionListener}.
*/
protected SelectionListener() {}

/** {@inheritDoc} */
public void valueChanged(ListSelectionEvent e) {
getHandler().valueChanged(e);
Expand Down Expand Up @@ -1325,6 +1331,11 @@ public String getDescription() {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class CancelSelectionAction extends AbstractAction {
/**
* Constructs a {@code CancelSelectionAction}.
*/
protected CancelSelectionAction() {}

/** {@inheritDoc} */
public void actionPerformed(ActionEvent e) {
getFileChooser().cancelSelection();
Expand All @@ -1336,6 +1347,11 @@ public void actionPerformed(ActionEvent e) {
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class UpdateAction extends AbstractAction {
/**
* Constructs an {@code UpdateAction}.
*/
protected UpdateAction() {}

/** {@inheritDoc} */
public void actionPerformed(ActionEvent e) {
JFileChooser fc = getFileChooser();
Expand Down
Loading

1 comment on commit 527a309

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 527a309 Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.