8380125: Formatting issue for few swing classes

Reviewed-by: honkar, azvegint
This commit is contained in:
Prasanta Sadhukhan 2026-03-18 01:14:16 +00:00
parent 50f81c5d7c
commit abb9c33ced
31 changed files with 56 additions and 56 deletions

View File

@ -1070,13 +1070,13 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
Action oldValue = getAction();
if (action==null || !action.equals(a)) {
action = a;
if (oldValue!=null) {
if (oldValue != null) {
removeActionListener(oldValue);
oldValue.removePropertyChangeListener(actionPropertyChangeListener);
actionPropertyChangeListener = null;
}
configurePropertiesFromAction(action);
if (action!=null) {
if (action != null) {
// Don't add if it is already a listener
if (!isListener(ActionListener.class, action)) {
addActionListener(action);

View File

@ -111,7 +111,7 @@ abstract class ActionPropertyChangeListener<T extends JComponent>
while ((r = (OwnedWeakReference)queue.poll()) != null) {
ActionPropertyChangeListener<?> oldPCL = r.getOwner();
Action oldAction = oldPCL.getAction();
if (oldAction!=null) {
if (oldAction != null) {
oldAction.removePropertyChangeListener(oldPCL);
}
}

View File

@ -213,7 +213,7 @@ class AncestorNotifier implements ComponentListener, PropertyChangeListener, Ser
public void propertyChange(PropertyChangeEvent evt) {
String s = evt.getPropertyName();
if (s!=null && (s.equals("parent") || s.equals("ancestor"))) {
if (s != null && (s.equals("parent") || s.equals("ancestor"))) {
JComponent component = (JComponent)evt.getSource();
if (evt.getNewValue() != null) {

View File

@ -145,7 +145,7 @@ class ArrayTable implements Cloneable {
*/
public Object get(Object key) {
Object value = null;
if (table !=null) {
if (table != null) {
if (isArray()) {
Object[] array = (Object[])table;
for (int i = 0; i<array.length-1; i+=2) {
@ -181,7 +181,7 @@ class ArrayTable implements Cloneable {
*/
public boolean containsKey(Object key) {
boolean contains = false;
if (table !=null) {
if (table != null) {
if (isArray()) {
Object[] array = (Object[])table;
for (int i = 0; i<array.length-1; i+=2) {
@ -206,7 +206,7 @@ class ArrayTable implements Cloneable {
if (key==null) {
return null;
}
if (table !=null) {
if (table != null) {
if (isArray()){
// Is key on the list?
int index = -1;

View File

@ -1103,13 +1103,13 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
Action oldValue = getAction();
if (action==null || !action.equals(a)) {
action = a;
if (oldValue!=null) {
if (oldValue != null) {
removeActionListener(oldValue);
oldValue.removePropertyChangeListener(actionPropertyChangeListener);
actionPropertyChangeListener = null;
}
configurePropertiesFromAction(action);
if (action!=null) {
if (action != null) {
// Don't add if it is already a listener
if (!isListener(ActionListener.class, action)) {
addActionListener(action);

View File

@ -2694,7 +2694,7 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
}
Rectangle newFirstRect = getCellBounds(newFirst,newFirst);
Rectangle firstRect = getCellBounds(first,first);
if ((newFirstRect != null) && (firstRect!=null)) {
if ((newFirstRect != null) && (firstRect != null)) {
while ( (newFirstRect.y + visibleRect.height <
firstRect.y + firstRect.height) &&
(newFirstRect.y < firstRect.y) ) {

View File

@ -975,7 +975,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
if (newFrame != frame) {
// Use the invoker's frame so that events
// are propagated properly
if (newFrame!=null) {
if (newFrame != null) {
this.frame = newFrame;
if(popup != null) {
setVisible(false);
@ -1012,7 +1012,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
*/
JPopupMenu getRootPopupMenu() {
JPopupMenu mp = this;
while((mp!=null) && (mp.isPopupMenu()!=true) &&
while((mp != null) && (mp.isPopupMenu()!=true) &&
(mp.getInvoker() != null) &&
(mp.getInvoker().getParent() instanceof JPopupMenu popupMenu)
) {
@ -1182,7 +1182,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
private static Frame getFrame(Component c) {
Component w = c;
while(!(w instanceof Frame) && (w!=null)) {
while(!(w instanceof Frame) && (w != null)) {
w = w.getParent();
}
return (Frame)w;

View File

@ -581,13 +581,13 @@ public class JTextField extends JTextComponent implements SwingConstants {
Action oldValue = getAction();
if (action==null || !action.equals(a)) {
action = a;
if (oldValue!=null) {
if (oldValue != null) {
removeActionListener(oldValue);
oldValue.removePropertyChangeListener(actionPropertyChangeListener);
actionPropertyChangeListener = null;
}
configurePropertiesFromAction(action);
if (action!=null) {
if (action != null) {
// Don't add if it is already a listener
if (!isListener(ActionListener.class, action)) {
addActionListener(action);

View File

@ -2087,7 +2087,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
value = expandedState.get(path);
if (value == null || !value)
return false;
} while( (path=path.getParentPath())!=null );
} while( (path=path.getParentPath()) != null );
return true;
}

View File

@ -330,7 +330,7 @@ class KeyboardManager {
return;
}
Hashtable<Object, Object> keyMap = containerMap.get(topContainer);
if (keyMap!=null) {
if (keyMap != null) {
Vector<?> v = (Vector)keyMap.get(JMenuBar.class);
if (v != null) {
v.removeElement(mb);

View File

@ -925,7 +925,7 @@ public class PopupFactory {
add to that, otherwise
add to the window. */
while (!(parent instanceof Window) &&
(parent!=null)) {
(parent != null)) {
parent = parent.getParent();
}

View File

@ -506,7 +506,7 @@ public class SwingUtilities implements SwingConstants
public static boolean isDescendingFrom(Component a,Component b) {
if(a == b)
return true;
for(Container p = a.getParent();p!=null;p=p.getParent())
for(Container p = a.getParent(); p != null; p = p.getParent())
if(p == b)
return true;
return false;

View File

@ -1169,7 +1169,7 @@ public class UIDefaults extends Hashtable<Object,Object>
*/
private Class<?>[] getClassArray(Object[] args) {
Class<?>[] types = null;
if (args!=null) {
if (args != null) {
types = new Class<?>[args.length];
for (int i = 0; i< args.length; i++) {
/* PENDING(ges): At present only the primitive types
@ -1199,7 +1199,7 @@ public class UIDefaults extends Hashtable<Object,Object>
private String printArgs(Object[] array) {
String s = "{";
if (array !=null) {
if (array != null) {
for (int i = 0 ; i < array.length-1; i++) {
s = s.concat(array[i] + ",");
}

View File

@ -1070,11 +1070,11 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup {
ComponentOrientation o =(ComponentOrientation)e.getNewValue();
JList<?> list = getList();
if (list!=null && list.getComponentOrientation()!=o) {
if (list != null && list.getComponentOrientation()!=o) {
list.setComponentOrientation(o);
}
if (scroller!=null && scroller.getComponentOrientation()!=o) {
if (scroller != null && scroller.getComponentOrientation()!=o) {
scroller.setComponentOrientation(o);
}

View File

@ -876,7 +876,7 @@ public class BasicListUI extends ListUI
}
Long l = (Long)UIManager.get("List.timeFactor");
timeFactor = (l!=null) ? l.longValue() : 1000L;
timeFactor = (l != null) ? l.longValue() : 1000L;
updateIsFileList();
}

View File

@ -125,7 +125,7 @@ public class BasicMenuBarUI extends MenuBarUI {
for (int i = 0; i < menuBar.getMenuCount(); i++) {
JMenu menu = menuBar.getMenu(i);
if (menu!=null)
if (menu != null)
menu.getModel().addChangeListener(changeListener);
}
menuBar.addContainerListener(containerListener);
@ -167,7 +167,7 @@ public class BasicMenuBarUI extends MenuBarUI {
* Uninstalls default properties.
*/
protected void uninstallDefaults() {
if (menuBar!=null) {
if (menuBar != null) {
LookAndFeel.uninstallBorder(menuBar);
}
}
@ -180,7 +180,7 @@ public class BasicMenuBarUI extends MenuBarUI {
for (int i = 0; i < menuBar.getMenuCount(); i++) {
JMenu menu = menuBar.getMenu(i);
if (menu !=null)
if (menu != null)
menu.getModel().removeChangeListener(changeListener);
}
@ -240,7 +240,7 @@ public class BasicMenuBarUI extends MenuBarUI {
int i,c;
for(i=0,c = menuBar.getMenuCount() ; i < c ; i++) {
JMenu menu = menuBar.getMenu(i);
if(menu !=null && menu.isSelected()) {
if(menu != null && menu.isSelected()) {
menuBar.getSelectionModel().setSelectedIndex(i);
break;
}
@ -277,7 +277,7 @@ public class BasicMenuBarUI extends MenuBarUI {
MenuElement[] me;
MenuElement[] subElements;
JMenu menu = menuBar.getMenu(0);
if (menu!=null) {
if (menu != null) {
me = new MenuElement[3];
me[0] = (MenuElement) menuBar;
me[1] = (MenuElement) menu;

View File

@ -908,7 +908,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
}
boolean isInPopup(Component src) {
for (Component c=src; c!=null; c=c.getParent()) {
for (Component c=src; c != null; c=c.getParent()) {
if (c instanceof Window) {
break;
} else if (c instanceof JPopupMenu) {

View File

@ -688,7 +688,7 @@ public class BasicSpinnerUI extends SpinnerUI
arrowButton = (JButton)e.getSource();
}
} else {
if (arrowButton!=null && !arrowButton.getModel().isPressed()
if (arrowButton != null && !arrowButton.getModel().isPressed()
&& autoRepeatTimer.isRunning()) {
autoRepeatTimer.stop();
spinner = null;

View File

@ -2273,7 +2273,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
JSplitPane parentSplitPane =
(JSplitPane)SwingUtilities.getAncestorOfClass(
JSplitPane.class, splitPane);
if (parentSplitPane!=null) {
if (parentSplitPane != null) {
parentSplitPane.requestFocus();
}
}
@ -2307,7 +2307,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
} while (splitPane.isAncestorOf(focusOn) &&
!focusFrom.contains(focusOn));
}
if ( focusOn!=null && !splitPane.isAncestorOf(focusOn) ) {
if ( focusOn != null && !splitPane.isAncestorOf(focusOn) ) {
focusOn.requestFocus();
}
}
@ -2323,7 +2323,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
if (focusOn != null) {
// don't change the focus if the new focused component belongs
// to the same splitpane and the same side
if ( focus!=null &&
if ( focus != null &&
( (SwingUtilities.isDescendingFrom(focus, left) &&
SwingUtilities.isDescendingFrom(focusOn, left)) ||
(SwingUtilities.isDescendingFrom(focus, right) &&
@ -2338,15 +2338,15 @@ public class BasicSplitPaneUI extends SplitPaneUI
Component left = splitPane.getLeftComponent();
Component right = splitPane.getRightComponent();
Component next;
if (focus!=null && SwingUtilities.isDescendingFrom(focus, left) &&
right!=null) {
if (focus != null && SwingUtilities.isDescendingFrom(focus, left) &&
right != null) {
next = getFirstAvailableComponent(right);
if (next != null) {
return next;
}
}
JSplitPane parentSplitPane = (JSplitPane)SwingUtilities.getAncestorOfClass(JSplitPane.class, splitPane);
if (parentSplitPane!=null) {
if (parentSplitPane != null) {
// focus next side of the parent split pane
next = getNextSide(parentSplitPane, focus);
} else {

View File

@ -528,7 +528,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
}
tabPane.removeContainerListener(getHandler());
if (htmlViews!=null) {
if (htmlViews != null) {
htmlViews.removeAllElements();
htmlViews = null;
}
@ -4090,7 +4090,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
setHtmlView(v, inserted, index);
}
} else { // Not HTML
if (htmlViews!=null) { // Add placeholder
if (htmlViews != null) { // Add placeholder
setHtmlView(null, inserted, index);
} // else nada!
}

View File

@ -980,7 +980,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
{
toolBar.setOrientation( orientation );
if (dragWindow !=null)
if (dragWindow != null)
dragWindow.setOrientation(orientation);
}
@ -1616,7 +1616,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
this.orientation = o;
Dimension size = getSize();
setSize(new Dimension(size.height, size.width));
if (offset!=null) {
if (offset != null) {
if( BasicGraphicsUtils.isLeftToRight(toolBar) ) {
setOffset(new Point(offset.y, offset.x));
} else if( o == JToolBar.HORIZONTAL ) {

View File

@ -943,7 +943,7 @@ public class BasicTreeUI extends TreeUI
lineTypeDashed = UIManager.getBoolean("Tree.lineTypeDashed");
Long l = (Long)UIManager.get("Tree.timeFactor");
timeFactor = (l!=null) ? l.longValue() : 1000L;
timeFactor = (l != null) ? l.longValue() : 1000L;
Object showsRootHandles = UIManager.get("Tree.showsRootHandles");
if (showsRootHandles != null) {

View File

@ -660,7 +660,7 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
ImageScalingHelper.paint(g, 0, 0, w, h, img, insets, dstInsets,
ImageScalingHelper.PaintType.PAINT9_STRETCH, ImageScalingHelper.PAINT_ALL);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
oldScalingHints!=null?oldScalingHints:RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
oldScalingHints != null ? oldScalingHints:RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
} else {
// render directly
paint0(g, c, w, h, extendedCacheKeys);

View File

@ -531,7 +531,7 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
public Object createValue(UIDefaults table) {
Object obj = null;
// check specified state
if (state!=null){
if (state != null){
obj = uiDefaults.get(prefix+"["+state+"]."+suffix);
}
// check enabled state

View File

@ -63,13 +63,13 @@ class SynthPainterImpl extends SynthPainter {
if (p != null) {
if (g instanceof Graphics2D){
Graphics2D gfx = (Graphics2D)g;
if (transform!=null){
if (transform != null) {
gfx.transform(transform);
}
gfx.translate(x, y);
p.paint(gfx, ctx.getComponent(), w, h);
gfx.translate(-x, -y);
if (transform!=null){
if (transform != null){
try {
gfx.transform(transform.createInverse());
} catch (NoninvertibleTransformException e) {
@ -85,7 +85,7 @@ class SynthPainterImpl extends SynthPainter {
BufferedImage img = new BufferedImage(w,h,
BufferedImage.TYPE_INT_ARGB);
Graphics2D gfx = img.createGraphics();
if (transform!=null){
if (transform != null){
gfx.transform(transform);
}
p.paint(gfx, ctx.getComponent(), w, h);

View File

@ -814,7 +814,7 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
public void propertyChange(PropertyChangeEvent evt) {
ComboBoxEditor newEditor = comboBox.getEditor();
if (editor != newEditor){
if (editorComponent!=null){
if (editorComponent != null) {
editorComponent.removeFocusListener(this);
}
editor = newEditor;

View File

@ -225,7 +225,7 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
private int getComponentState(JComponent c) {
int baseState = SynthLookAndFeel.getComponentState(c);
if (viewportViewFocusHandler!=null && viewportViewHasFocus){
if (viewportViewFocusHandler != null && viewportViewHasFocus) {
baseState = baseState | FOCUSED;
}
return baseState;

View File

@ -1181,7 +1181,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
Hashtable<String, Action> h = new Hashtable<String, Action>();
for (Action a : actions) {
String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a);
h.put((value != null ? value : ""), a);
}
for (KeyBinding binding : bindings) {
Action a = h.get(binding.actionName);

View File

@ -107,11 +107,11 @@ public abstract class TextAction extends AbstractAction {
Hashtable<String, Action> h = new Hashtable<String, Action>();
for (Action a : list1) {
String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a);
h.put((value != null ? value : ""), a);
}
for (Action a : list2) {
String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a);
h.put((value != null ? value : ""), a);
}
Action[] actions = new Action[h.size()];
int index = 0;

View File

@ -259,7 +259,7 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor,
((MouseEvent)event).getY());
editable = (lastPath != null && path != null &&
lastPath.equals(path));
if (path!=null) {
if (path != null) {
lastRow = tree.getRowForPath(path);
Object value = path.getLastPathComponent();
boolean isSelected = tree.isRowSelected(lastRow);

View File

@ -1646,17 +1646,17 @@ public class SwingUtilities2 {
if (container.isFocusCycleRoot()) {
FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
Component comp = policy.getDefaultComponent(container);
if (comp!=null) {
if (comp != null) {
comp.requestFocus(FocusEvent.Cause.TRAVERSAL);
return comp;
}
}
Container rootAncestor = container.getFocusCycleRootAncestor();
if (rootAncestor!=null) {
if (rootAncestor != null) {
FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
Component comp = policy.getComponentAfter(rootAncestor, container);
if (comp!=null && SwingUtilities.isDescendingFrom(comp, container)) {
if (comp != null && SwingUtilities.isDescendingFrom(comp, container)) {
comp.requestFocus(FocusEvent.Cause.TRAVERSAL);
return comp;
}