mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8274640: Cleanup unnecessary null comparison before instanceof check in java.desktop
Reviewed-by: aivanov
This commit is contained in:
parent
dda8f26ce0
commit
18c54b4e1a
122 changed files with 411 additions and 526 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -128,7 +128,7 @@ public abstract class AquaBorder implements Border, UIResource {
|
|||
if (!((javax.swing.text.JTextComponent)focusable).isEditable()) return false;
|
||||
}
|
||||
|
||||
return (focusable != null && focusable instanceof JComponent && ((JComponent)focusable).hasFocus());
|
||||
return (focusable instanceof JComponent jComponent) && jComponent.hasFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -145,9 +145,9 @@ public abstract class AquaButtonBorder extends AquaBorder implements Border, UIR
|
|||
* @param c the component for which this border insets value applies
|
||||
*/
|
||||
public Insets getBorderInsets(final Component c) {
|
||||
if (c == null || !(c instanceof AbstractButton)) return new Insets(0, 0, 0, 0);
|
||||
if (!(c instanceof AbstractButton button)) return new Insets(0, 0, 0, 0);
|
||||
|
||||
Insets margin = ((AbstractButton)c).getMargin();
|
||||
Insets margin = button.getMargin();
|
||||
margin = (margin == null) ? new InsetsUIResource(0, 0, 0, 0) : (Insets)margin.clone();
|
||||
|
||||
margin.top += sizeVariant.margins.top;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -598,8 +598,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
|
|||
final boolean editable = comboBox.isEditable();
|
||||
|
||||
final Dimension size;
|
||||
if (!editable && arrowButton != null && arrowButton instanceof AquaComboBoxButton) {
|
||||
final AquaComboBoxButton button = (AquaComboBoxButton)arrowButton;
|
||||
if (!editable && arrowButton instanceof final AquaComboBoxButton button) {
|
||||
final Insets buttonInsets = button.getInsets();
|
||||
// Insets insets = comboBox.getInsets();
|
||||
final Insets insets = new Insets(0, 5, 0, 25);//comboBox.getInsets();
|
||||
|
|
|
@ -519,14 +519,14 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||
|
||||
void setPackageIsTraversable(final Object o) {
|
||||
int newProp = -1;
|
||||
if (o != null && o instanceof String) newProp = parseTraversableProperty((String)o);
|
||||
if (o instanceof String s) newProp = parseTraversableProperty(s);
|
||||
if (newProp != -1) fPackageIsTraversable = newProp;
|
||||
else fPackageIsTraversable = sGlobalPackageIsTraversable;
|
||||
}
|
||||
|
||||
void setApplicationIsTraversable(final Object o) {
|
||||
int newProp = -1;
|
||||
if (o != null && o instanceof String) newProp = parseTraversableProperty((String)o);
|
||||
if (o instanceof String s) newProp = parseTraversableProperty(s);
|
||||
if (newProp != -1) fApplicationIsTraversable = newProp;
|
||||
else fApplicationIsTraversable = sGlobalApplicationIsTraversable;
|
||||
}
|
||||
|
@ -1985,11 +1985,11 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||
|
||||
static {
|
||||
Object o = UIManager.get(PACKAGE_TRAVERSABLE_PROPERTY);
|
||||
if (o != null && o instanceof String) sGlobalPackageIsTraversable = parseTraversableProperty((String)o);
|
||||
if (o instanceof String s) sGlobalPackageIsTraversable = parseTraversableProperty(s);
|
||||
else sGlobalPackageIsTraversable = kOpenConditional;
|
||||
|
||||
o = UIManager.get(APPLICATION_TRAVERSABLE_PROPERTY);
|
||||
if (o != null && o instanceof String) sGlobalApplicationIsTraversable = parseTraversableProperty((String)o);
|
||||
if (o instanceof String s) sGlobalApplicationIsTraversable = parseTraversableProperty(s);
|
||||
else sGlobalApplicationIsTraversable = kOpenConditional;
|
||||
}
|
||||
static final String sDataPrefix = "FileChooser.";
|
||||
|
|
|
@ -188,8 +188,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
|
|||
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor(AquaMnemonicHandler.getInstance());
|
||||
|
||||
final PopupFactory popupFactory = PopupFactory.getSharedInstance();
|
||||
if (popupFactory != null && popupFactory instanceof ScreenPopupFactory) {
|
||||
((ScreenPopupFactory)popupFactory).setActive(false);
|
||||
if (popupFactory instanceof ScreenPopupFactory spf) {
|
||||
spf.setActive(false);
|
||||
}
|
||||
|
||||
super.uninitialize();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -75,8 +75,7 @@ public class AquaRootPaneUI extends BasicRootPaneUI implements AncestorListener,
|
|||
// it is not since we are going to grab the one that was set on the JFrame. :(
|
||||
final Component parent = c.getParent();
|
||||
|
||||
if (parent != null && parent instanceof JFrame) {
|
||||
final JFrame frameParent = (JFrame)parent;
|
||||
if (parent instanceof JFrame frameParent) {
|
||||
final Color bg = frameParent.getBackground();
|
||||
if (bg == null || bg instanceof UIResource) {
|
||||
frameParent.setBackground(UIManager.getColor("Panel.background"));
|
||||
|
@ -126,8 +125,8 @@ public class AquaRootPaneUI extends BasicRootPaneUI implements AncestorListener,
|
|||
final Window owningWindow = SwingUtilities.getWindowAncestor(jmb);
|
||||
|
||||
// Could be a JDialog, and may have been added to a JRootPane not yet in a window.
|
||||
if (owningWindow != null && owningWindow instanceof JFrame) {
|
||||
((AquaMenuBarUI)mbui).setScreenMenuBar((JFrame)owningWindow);
|
||||
if (owningWindow instanceof JFrame frame) {
|
||||
((AquaMenuBarUI)mbui).setScreenMenuBar(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +153,8 @@ public class AquaRootPaneUI extends BasicRootPaneUI implements AncestorListener,
|
|||
final Window owningWindow = SwingUtilities.getWindowAncestor(jmb);
|
||||
|
||||
// Could be a JDialog, and may have been added to a JRootPane not yet in a window.
|
||||
if (owningWindow != null && owningWindow instanceof JFrame) {
|
||||
((AquaMenuBarUI)mbui).clearScreenMenuBar((JFrame)owningWindow);
|
||||
if (owningWindow instanceof JFrame frame) {
|
||||
((AquaMenuBarUI)mbui).clearScreenMenuBar(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -266,8 +266,8 @@ public class AquaSliderUI extends BasicSliderUI implements Sizeable {
|
|||
if (slider.getPaintTicks() || slider.getPaintLabels()) return true;
|
||||
|
||||
final Object shouldPaintArrowThumbProperty = slider.getClientProperty("Slider.paintThumbArrowShape");
|
||||
if (shouldPaintArrowThumbProperty != null && shouldPaintArrowThumbProperty instanceof Boolean) {
|
||||
return ((Boolean)shouldPaintArrowThumbProperty).booleanValue();
|
||||
if (shouldPaintArrowThumbProperty instanceof Boolean b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -103,9 +103,8 @@ public class AquaTableHeaderUI extends BasicTableHeaderUI {
|
|||
}
|
||||
|
||||
final TableHeaderUI headerUI = target.getUI();
|
||||
if (headerUI == null || !(headerUI instanceof AquaTableHeaderUI)) return;
|
||||
if (!(headerUI instanceof AquaTableHeaderUI aquaHeaderUI)) return;
|
||||
|
||||
final AquaTableHeaderUI aquaHeaderUI = (AquaTableHeaderUI)headerUI;
|
||||
aquaHeaderUI.sortColumn = tableColumn.getModelIndex();
|
||||
aquaHeaderUI.sortOrder = sortDirection;
|
||||
final AquaTableCellRenderer renderer = aquaHeaderUI.new AquaTableCellRenderer();
|
||||
|
@ -145,8 +144,7 @@ public class AquaTableHeaderUI extends BasicTableHeaderUI {
|
|||
}
|
||||
|
||||
protected static TableColumn getTableColumn(final JTableHeader target, final Object value) {
|
||||
if (value == null || !(value instanceof Integer)) return null;
|
||||
final int columnIndex = ((Integer)value).intValue();
|
||||
if (!(value instanceof Integer columnIndex)) return null;
|
||||
|
||||
final TableColumnModel columnModel = target.getColumnModel();
|
||||
if (columnIndex < 0 || columnIndex >= columnModel.getColumnCount()) return null;
|
||||
|
|
|
@ -351,11 +351,8 @@ final class ScreenMenu extends Menu
|
|||
// Tell our parent to add/remove us
|
||||
final MenuContainer parent = getParent();
|
||||
|
||||
if (parent != null) {
|
||||
if (parent instanceof ScreenMenu) {
|
||||
final ScreenMenu sm = (ScreenMenu)parent;
|
||||
sm.setChildVisible(fInvoker, b);
|
||||
}
|
||||
if (parent instanceof ScreenMenu sm) {
|
||||
sm.setChildVisible(fInvoker, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,9 +283,9 @@ public final class CFontManager extends SunFontManager {
|
|||
if (realFamily == null) return false;
|
||||
|
||||
Font2D realFont = realFamily.getFontWithExactStyleMatch(style);
|
||||
if (realFont == null || !(realFont instanceof CFont)) return false;
|
||||
if (!(realFont instanceof CFont cFont)) return false;
|
||||
|
||||
CFont newFont = new CFont((CFont)realFont, logicalFamilyName);
|
||||
CFont newFont = new CFont(cFont, logicalFamilyName);
|
||||
registerGenericFont(newFont, true);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -627,8 +627,8 @@ class CAccessibility implements PropertyChangeListener {
|
|||
return invokeAndWait(new Callable<Accessible>() {
|
||||
public Accessible call() throws Exception {
|
||||
Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if (c == null || !(c instanceof Accessible)) return null;
|
||||
return CAccessible.getCAccessible((Accessible)c);
|
||||
if (!(c instanceof Accessible accessible)) return null;
|
||||
return CAccessible.getCAccessible(accessible);
|
||||
}
|
||||
}, c);
|
||||
}
|
||||
|
|
|
@ -244,12 +244,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||
c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
|
||||
}},
|
||||
new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||
if (value == null || !(value instanceof java.io.File)) {
|
||||
if (!(value instanceof java.io.File file)) {
|
||||
c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null));
|
||||
return;
|
||||
}
|
||||
|
||||
final String filename = ((java.io.File)value).getAbsolutePath();
|
||||
final String filename = file.getAbsolutePath();
|
||||
c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
|
||||
}},
|
||||
new Property<CPlatformWindow>(WINDOW_FULL_CONTENT) {
|
||||
|
|
|
@ -845,10 +845,10 @@ public final class CPrinterJob extends RasterPrinterJob {
|
|||
@Override
|
||||
protected MediaSize getMediaSize(Media media, PrintService service,
|
||||
PageFormat page) {
|
||||
if (media == null || !(media instanceof MediaSizeName)) {
|
||||
if (!(media instanceof MediaSizeName msn)) {
|
||||
return getDefaultMediaSize(page);
|
||||
}
|
||||
MediaSize size = MediaSize.getMediaSizeForName((MediaSizeName) media);
|
||||
MediaSize size = MediaSize.getMediaSizeForName(msn);
|
||||
return size != null ? size : getDefaultMediaSize(page);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -210,10 +210,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
|
|||
|
||||
IIOMetadata imageMetadata = image.getMetadata();
|
||||
BMPMetadata bmpImageMetadata = null;
|
||||
if (imageMetadata != null
|
||||
&& imageMetadata instanceof BMPMetadata)
|
||||
{
|
||||
bmpImageMetadata = (BMPMetadata)imageMetadata;
|
||||
if (imageMetadata instanceof BMPMetadata bmp) {
|
||||
bmpImageMetadata = bmp;
|
||||
} else {
|
||||
ImageTypeSpecifier imageType =
|
||||
new ImageTypeSpecifier(colorModel, sampleModel);
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class SimpleCMYKColorSpace extends ColorSpace {
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return o != null && o instanceof SimpleCMYKColorSpace;
|
||||
return o instanceof SimpleCMYKColorSpace;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
|
|
@ -248,8 +248,7 @@ class GIFWritableImageMetadata extends GIFImageMetadata {
|
|||
|
||||
Object applicationExtensionData =
|
||||
applicationExtension.getUserObject();
|
||||
if (applicationExtensionData == null ||
|
||||
!(applicationExtensionData instanceof byte[])) {
|
||||
if (!(applicationExtensionData instanceof byte[])) {
|
||||
fatal(applicationExtension,
|
||||
"Bad user object in ApplicationExtension!");
|
||||
}
|
||||
|
|
|
@ -371,8 +371,8 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
|
|||
|
||||
JPEGImageWriteParam jparam = null;
|
||||
|
||||
if ((param != null) && (param instanceof JPEGImageWriteParam)) {
|
||||
jparam = (JPEGImageWriteParam) param;
|
||||
if (param instanceof JPEGImageWriteParam p) {
|
||||
jparam = p;
|
||||
if (!jparam.areTablesSet()) {
|
||||
jparam = null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -274,8 +274,8 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor {
|
|||
|
||||
// Initialize the ImageWriteParam.
|
||||
if(this.JPEGParam == null) {
|
||||
if(param != null && param instanceof JPEGImageWriteParam) {
|
||||
JPEGParam = (JPEGImageWriteParam)param;
|
||||
if (param instanceof JPEGImageWriteParam p) {
|
||||
JPEGParam = p;
|
||||
} else {
|
||||
JPEGParam =
|
||||
new JPEGImageWriteParam(writer != null ?
|
||||
|
|
|
@ -2895,7 +2895,7 @@ public class TIFFImageWriter extends ImageWriter {
|
|||
int numThumbs = thumbnails.size();
|
||||
for(int i = 0; i < numThumbs; i++) {
|
||||
Object thumb = thumbnails.get(i);
|
||||
if(thumb == null || !(thumb instanceof BufferedImage)) {
|
||||
if (!(thumb instanceof BufferedImage)) {
|
||||
throw new IllegalArgumentException
|
||||
("thumbnails contains null references or objects other than BufferedImages!");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -787,8 +787,8 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
|||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
if (value != null && value instanceof FileFilter) {
|
||||
setText(((FileFilter)value).getDescription());
|
||||
if (value instanceof FileFilter fileFilter) {
|
||||
setText(fileFilter.getDescription());
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -110,10 +110,10 @@ public class MotifMenuUI extends BasicMenuUI
|
|||
manager.clearSelectedPath();
|
||||
} else {
|
||||
Container cnt = menu.getParent();
|
||||
if(cnt != null && cnt instanceof JMenuBar) {
|
||||
if (cnt instanceof JMenuBar menuBar) {
|
||||
MenuElement[] me = new MenuElement[2];
|
||||
me[0]=(MenuElement)cnt;
|
||||
me[1]=menu;
|
||||
me[0] = menuBar;
|
||||
me[1] = menu;
|
||||
manager.setSelectedPath(me);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -576,11 +576,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
|
|||
if (midiOutReceiver == oldR) {
|
||||
midiOutReceiver = null;
|
||||
}
|
||||
if (newR != null) {
|
||||
if ((newR instanceof MidiOutDevice.MidiOutReceiver)
|
||||
if ((newR instanceof MidiOutDevice.MidiOutReceiver newReceiver)
|
||||
&& (midiOutReceiver == null)) {
|
||||
midiOutReceiver = ((MidiOutDevice.MidiOutReceiver) newR);
|
||||
}
|
||||
midiOutReceiver = newReceiver;
|
||||
}
|
||||
optimizedReceiverCount =
|
||||
((midiOutReceiver!=null)?1:0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -293,8 +293,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
|
|||
format.getSampleRate(), sourceFormat.isBigEndian());
|
||||
nrofchannels = targetFormat.getChannels();
|
||||
Object interpolation = format.getProperty("interpolation");
|
||||
if (interpolation != null && (interpolation instanceof String)) {
|
||||
String resamplerType = (String) interpolation;
|
||||
if (interpolation instanceof String resamplerType) {
|
||||
if (resamplerType.equalsIgnoreCase("point"))
|
||||
this.resampler = new SoftPointResampler();
|
||||
if (resamplerType.equalsIgnoreCase("linear"))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -115,7 +115,7 @@ final class PortMixer extends AbstractMixer {
|
|||
public Line getLine(Line.Info info) throws LineUnavailableException {
|
||||
Line.Info fullInfo = getLineInfo(info);
|
||||
|
||||
if ((fullInfo != null) && (fullInfo instanceof Port.Info)) {
|
||||
if (fullInfo instanceof Port.Info) {
|
||||
for (int i = 0; i < portInfos.length; i++) {
|
||||
if (fullInfo.equals(portInfos[i])) {
|
||||
return getPort(i);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -102,8 +102,7 @@ public abstract class SoftMixingDataLine implements DataLine {
|
|||
format.getSampleRate(), sourceFormat.isBigEndian());
|
||||
nrofchannels = targetFormat.getChannels();
|
||||
Object interpolation = format.getProperty("interpolation");
|
||||
if (interpolation != null && (interpolation instanceof String)) {
|
||||
String resamplerType = (String) interpolation;
|
||||
if (interpolation instanceof String resamplerType) {
|
||||
if (resamplerType.equalsIgnoreCase("point"))
|
||||
this.resampler = new SoftPointResampler();
|
||||
if (resamplerType.equalsIgnoreCase("linear"))
|
||||
|
|
|
@ -574,25 +574,25 @@ public final class SoftSynthesizer implements AudioSynthesizer,
|
|||
|
||||
@Override
|
||||
public boolean loadInstrument(Instrument instrument) {
|
||||
if (instrument == null || (!(instrument instanceof ModelInstrument))) {
|
||||
if (!(instrument instanceof ModelInstrument modelInstrument)) {
|
||||
throw new IllegalArgumentException("Unsupported instrument: " +
|
||||
instrument);
|
||||
}
|
||||
List<ModelInstrument> instruments = new ArrayList<>();
|
||||
instruments.add((ModelInstrument)instrument);
|
||||
instruments.add(modelInstrument);
|
||||
return loadInstruments(instruments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadInstrument(Instrument instrument) {
|
||||
if (instrument == null || (!(instrument instanceof ModelInstrument))) {
|
||||
if (!(instrument instanceof ModelInstrument modelInstrument)) {
|
||||
throw new IllegalArgumentException("Unsupported instrument: " +
|
||||
instrument);
|
||||
}
|
||||
if (!isOpen())
|
||||
return;
|
||||
|
||||
String pat = patchToString(instrument.getPatch());
|
||||
String pat = patchToString(modelInstrument.getPatch());
|
||||
synchronized (control_mutex) {
|
||||
for (SoftChannel c: channels)
|
||||
c.current_instrument = null;
|
||||
|
@ -841,11 +841,11 @@ public final class SoftSynthesizer implements AudioSynthesizer,
|
|||
public boolean loadAllInstruments(Soundbank soundbank) {
|
||||
List<ModelInstrument> instruments = new ArrayList<>();
|
||||
for (Instrument ins: soundbank.getInstruments()) {
|
||||
if (ins == null || !(ins instanceof ModelInstrument)) {
|
||||
if (!(ins instanceof ModelInstrument modelInstrument)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported instrument: " + ins);
|
||||
}
|
||||
instruments.add((ModelInstrument)ins);
|
||||
instruments.add(modelInstrument);
|
||||
}
|
||||
return loadInstruments(instruments);
|
||||
}
|
||||
|
@ -870,11 +870,11 @@ public final class SoftSynthesizer implements AudioSynthesizer,
|
|||
List<ModelInstrument> instruments = new ArrayList<>();
|
||||
for (Patch patch: patchList) {
|
||||
Instrument ins = soundbank.getInstrument(patch);
|
||||
if (ins == null || !(ins instanceof ModelInstrument)) {
|
||||
if (!(ins instanceof ModelInstrument modelInstrument)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported instrument: " + ins);
|
||||
}
|
||||
instruments.add((ModelInstrument)ins);
|
||||
instruments.add(modelInstrument);
|
||||
}
|
||||
return loadInstruments(instruments);
|
||||
}
|
||||
|
|
|
@ -355,8 +355,7 @@ public abstract class AWTEvent extends EventObject {
|
|||
Component comp = null;
|
||||
if (newSource instanceof Component) {
|
||||
comp = (Component)newSource;
|
||||
while (comp != null && comp.peer != null &&
|
||||
(comp.peer instanceof LightweightPeer)) {
|
||||
while (comp != null && (comp.peer instanceof LightweightPeer)) {
|
||||
comp = comp.parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4944,8 +4944,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||
// the active/passive/peered clients loose focus.
|
||||
if (id == FocusEvent.FOCUS_GAINED) {
|
||||
InputContext inputContext = getInputContext();
|
||||
if (inputContext != null && inputContext instanceof sun.awt.im.InputContext) {
|
||||
((sun.awt.im.InputContext)inputContext).disableNativeIM();
|
||||
if (inputContext instanceof sun.awt.im.InputContext ctx) {
|
||||
ctx.disableNativeIM();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3891,18 +3891,18 @@ public class Container extends Component {
|
|||
|
||||
public void componentAdded(ContainerEvent e) {
|
||||
Component c = e.getChild();
|
||||
if (c != null && c instanceof Accessible) {
|
||||
if (c instanceof Accessible accessible) {
|
||||
AccessibleAWTContainer.this.firePropertyChange(
|
||||
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
|
||||
null, ((Accessible) c).getAccessibleContext());
|
||||
null, accessible.getAccessibleContext());
|
||||
}
|
||||
}
|
||||
public void componentRemoved(ContainerEvent e) {
|
||||
Component c = e.getChild();
|
||||
if (c != null && c instanceof Accessible) {
|
||||
if (c instanceof Accessible accessible) {
|
||||
AccessibleAWTContainer.this.firePropertyChange(
|
||||
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
|
||||
((Accessible) c).getAccessibleContext(), null);
|
||||
accessible.getAccessibleContext(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,8 +373,7 @@ public abstract class MenuComponent implements java.io.Serializable {
|
|||
Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
|
||||
|
||||
if (newEventsOnly ||
|
||||
(parent != null && parent instanceof MenuComponent &&
|
||||
((MenuComponent)parent).newEventsOnly)) {
|
||||
(parent instanceof MenuComponent mc && mc.newEventsOnly)) {
|
||||
if (eventEnabled(e)) {
|
||||
processEvent(e);
|
||||
} else if (e instanceof ActionEvent && parent != null) {
|
||||
|
|
|
@ -793,7 +793,7 @@ public class DropTarget implements DropTargetListener, Serializable {
|
|||
*/
|
||||
|
||||
protected void initializeAutoscrolling(Point p) {
|
||||
if (component == null || !(component instanceof Autoscroll)) return;
|
||||
if (!(component instanceof Autoscroll)) return;
|
||||
|
||||
autoScroller = createDropTargetAutoScroller(component, p);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -105,7 +105,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter {
|
|||
|
||||
private int[] calcRow() {
|
||||
float origmult = ((float) srcWidth) * srcHeight;
|
||||
if (outpixbuf == null || !(outpixbuf instanceof int[])) {
|
||||
if (!(outpixbuf instanceof int[])) {
|
||||
outpixbuf = new int[destWidth];
|
||||
}
|
||||
int[] outpix = (int[]) outpixbuf;
|
||||
|
|
|
@ -1185,11 +1185,10 @@ public class ComponentSampleModel extends SampleModel
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) || !(o instanceof ComponentSampleModel)) {
|
||||
if (!(o instanceof ComponentSampleModel that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ComponentSampleModel that = (ComponentSampleModel)o;
|
||||
return this.width == that.width &&
|
||||
this.height == that.height &&
|
||||
this.numBands == that.numBands &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -655,11 +655,10 @@ public class MultiPixelPackedSampleModel extends SampleModel
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) || !(o instanceof MultiPixelPackedSampleModel)) {
|
||||
if (!(o instanceof MultiPixelPackedSampleModel that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiPixelPackedSampleModel that = (MultiPixelPackedSampleModel)o;
|
||||
return this.width == that.width &&
|
||||
this.height == that.height &&
|
||||
this.numBands == that.numBands &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -126,8 +126,8 @@ public class ReplicateScaleFilter extends ImageFilter {
|
|||
String key = "rescale";
|
||||
String val = destWidth + "x" + destHeight;
|
||||
Object o = p.get(key);
|
||||
if (o != null && o instanceof String) {
|
||||
val = ((String) o) + ", " + val;
|
||||
if (o instanceof String s) {
|
||||
val = s + ", " + val;
|
||||
}
|
||||
p.put(key, val);
|
||||
super.setProperties(p);
|
||||
|
@ -194,8 +194,8 @@ public class ReplicateScaleFilter extends ImageFilter {
|
|||
int dx1 = (2 * x * destWidth + srcWidth - 1) / (2 * srcWidth);
|
||||
int dy1 = (2 * y * destHeight + srcHeight - 1) / (2 * srcHeight);
|
||||
byte[] outpix;
|
||||
if (outpixbuf != null && outpixbuf instanceof byte[]) {
|
||||
outpix = (byte[]) outpixbuf;
|
||||
if (outpixbuf instanceof byte[] outbytes) {
|
||||
outpix = outbytes;
|
||||
} else {
|
||||
outpix = new byte[destWidth];
|
||||
outpixbuf = outpix;
|
||||
|
@ -235,8 +235,8 @@ public class ReplicateScaleFilter extends ImageFilter {
|
|||
int dx1 = (2 * x * destWidth + srcWidth - 1) / (2 * srcWidth);
|
||||
int dy1 = (2 * y * destHeight + srcHeight - 1) / (2 * srcHeight);
|
||||
int[] outpix;
|
||||
if (outpixbuf != null && outpixbuf instanceof int[]) {
|
||||
outpix = (int[]) outpixbuf;
|
||||
if (outpixbuf instanceof int[] outints) {
|
||||
outpix = outints;
|
||||
} else {
|
||||
outpix = new int[destWidth];
|
||||
outpixbuf = outpix;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -754,11 +754,10 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) || !(o instanceof SinglePixelPackedSampleModel)) {
|
||||
if (!(o instanceof SinglePixelPackedSampleModel that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SinglePixelPackedSampleModel that = (SinglePixelPackedSampleModel)o;
|
||||
return this.width == that.width &&
|
||||
this.height == that.height &&
|
||||
this.numBands == that.numBands &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -407,8 +407,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (obj != null && obj instanceof IndexedPropertyDescriptor) {
|
||||
IndexedPropertyDescriptor other = (IndexedPropertyDescriptor)obj;
|
||||
if (obj instanceof IndexedPropertyDescriptor other) {
|
||||
Method otherIndexedReadMethod = other.getIndexedReadMethod();
|
||||
Method otherIndexedWriteMethod = other.getIndexedWriteMethod();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -503,8 +503,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor other = (PropertyDescriptor)obj;
|
||||
if (obj instanceof PropertyDescriptor other) {
|
||||
Method otherReadMethod = other.getReadMethod();
|
||||
Method otherWriteMethod = other.getWriteMethod();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -328,14 +328,10 @@ public class ImageTypeSpecifier {
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) ||
|
||||
!(o instanceof ImageTypeSpecifier.Interleaved)) {
|
||||
if (!(o instanceof Interleaved that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageTypeSpecifier.Interleaved that =
|
||||
(ImageTypeSpecifier.Interleaved)o;
|
||||
|
||||
if ((!(this.colorSpace.equals(that.colorSpace))) ||
|
||||
(this.dataType != that.dataType) ||
|
||||
(this.hasAlpha != that.hasAlpha) ||
|
||||
|
@ -472,14 +468,10 @@ public class ImageTypeSpecifier {
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) ||
|
||||
!(o instanceof ImageTypeSpecifier.Banded)) {
|
||||
if (!(o instanceof Banded that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageTypeSpecifier.Banded that =
|
||||
(ImageTypeSpecifier.Banded)o;
|
||||
|
||||
if ((!(this.colorSpace.equals(that.colorSpace))) ||
|
||||
(this.dataType != that.dataType) ||
|
||||
(this.hasAlpha != that.hasAlpha) ||
|
||||
|
@ -1095,11 +1087,10 @@ public class ImageTypeSpecifier {
|
|||
* {@code ImageTypeSpecifier}.
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) || !(o instanceof ImageTypeSpecifier)) {
|
||||
if (!(o instanceof ImageTypeSpecifier that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageTypeSpecifier that = (ImageTypeSpecifier)o;
|
||||
return (colorModel.equals(that.colorModel)) &&
|
||||
(sampleModel.equals(that.sampleModel));
|
||||
}
|
||||
|
|
|
@ -537,10 +537,8 @@ public class DocFlavor implements Serializable, Cloneable {
|
|||
* {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
return
|
||||
obj != null &&
|
||||
obj instanceof DocFlavor &&
|
||||
getStringValue().equals (((DocFlavor) obj).getStringValue());
|
||||
return obj instanceof DocFlavor other &&
|
||||
getStringValue().equals(other.getStringValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,10 +141,9 @@ class MimeType implements Serializable, Cloneable {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public boolean equals(Object o) {
|
||||
return (o != null &&
|
||||
o instanceof Map.Entry &&
|
||||
getKey().equals (((Map.Entry) o).getKey()) &&
|
||||
getValue().equals(((Map.Entry) o).getValue()));
|
||||
return o instanceof Map.Entry<?, ?> entry &&
|
||||
getKey().equals(entry.getKey()) &&
|
||||
getValue().equals(entry.getValue());
|
||||
}
|
||||
public int hashCode() {
|
||||
return getKey().hashCode() ^ getValue().hashCode();
|
||||
|
@ -290,9 +289,8 @@ class MimeType implements Serializable, Cloneable {
|
|||
* {@code false} otherwise
|
||||
*/
|
||||
public boolean equals (Object obj) {
|
||||
return(obj != null &&
|
||||
obj instanceof MimeType &&
|
||||
getStringValue().equals(((MimeType) obj).getStringValue()));
|
||||
return obj instanceof MimeType mimeType &&
|
||||
getStringValue().equals(mimeType.getStringValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,9 +115,8 @@ public abstract class DateTimeSyntax implements Serializable, Cloneable {
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (object != null &&
|
||||
object instanceof DateTimeSyntax &&
|
||||
value.equals(((DateTimeSyntax) object).value));
|
||||
return object instanceof DateTimeSyntax other &&
|
||||
value.equals(other.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -345,10 +345,8 @@ public class HashAttributeSet implements AttributeSet, Serializable {
|
|||
* value
|
||||
*/
|
||||
public boolean containsValue(Attribute attribute) {
|
||||
return
|
||||
attribute != null &&
|
||||
attribute instanceof Attribute &&
|
||||
attribute.equals(attrMap.get(attribute.getCategory()));
|
||||
return attribute != null &&
|
||||
attribute.equals(attrMap.get(attribute.getCategory()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -441,11 +439,10 @@ public class HashAttributeSet implements AttributeSet, Serializable {
|
|||
* set
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
if (object == null || !(object instanceof AttributeSet)) {
|
||||
if (!(object instanceof AttributeSet aset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AttributeSet aset = (AttributeSet)object;
|
||||
if (aset.size() != size()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -108,9 +108,8 @@ public abstract class IntegerSyntax implements Serializable, Cloneable {
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
|
||||
return (object != null && object instanceof IntegerSyntax &&
|
||||
value == ((IntegerSyntax) object).value);
|
||||
return object instanceof IntegerSyntax other &&
|
||||
value == other.value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -267,13 +267,9 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable {
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
|
||||
return(object != null &&
|
||||
object instanceof ResolutionSyntax &&
|
||||
this.crossFeedResolution ==
|
||||
((ResolutionSyntax) object).crossFeedResolution &&
|
||||
this.feedResolution ==
|
||||
((ResolutionSyntax) object).feedResolution);
|
||||
return object instanceof ResolutionSyntax other &&
|
||||
this.crossFeedResolution == other.crossFeedResolution &&
|
||||
this.feedResolution == other.feedResolution;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -483,9 +483,9 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable {
|
|||
* set-of-integer attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
if (object != null && object instanceof SetOfIntegerSyntax) {
|
||||
if (object instanceof SetOfIntegerSyntax other) {
|
||||
int[][] myMembers = this.members;
|
||||
int[][] otherMembers = ((SetOfIntegerSyntax) object).members;
|
||||
int[][] otherMembers = other.members;
|
||||
int m = myMembers.length;
|
||||
int n = otherMembers.length;
|
||||
if (m == n) {
|
||||
|
|
|
@ -264,10 +264,9 @@ public abstract class Size2DSyntax implements Serializable, Cloneable {
|
|||
* two-dimensional size attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof Size2DSyntax &&
|
||||
this.x == ((Size2DSyntax) object).x &&
|
||||
this.y == ((Size2DSyntax) object).y);
|
||||
return object instanceof Size2DSyntax size2DSyntax &&
|
||||
this.x == size2DSyntax.x &&
|
||||
this.y == size2DSyntax.y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -132,10 +132,9 @@ public abstract class TextSyntax implements Serializable, Cloneable {
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof TextSyntax &&
|
||||
this.value.equals (((TextSyntax) object).value) &&
|
||||
this.locale.equals (((TextSyntax) object).locale));
|
||||
return object instanceof TextSyntax other &&
|
||||
this.value.equals(other.value) &&
|
||||
this.locale.equals(other.locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -101,9 +101,8 @@ public abstract class URISyntax implements Serializable, Cloneable {
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof URISyntax &&
|
||||
this.uri.equals (((URISyntax) object).uri));
|
||||
return object instanceof URISyntax other &&
|
||||
this.uri.equals(other.uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -90,9 +90,9 @@ public abstract class Media extends EnumSyntax
|
|||
* attribute, {@code false} otherwise
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null && object instanceof Media &&
|
||||
object.getClass() == this.getClass() &&
|
||||
((Media)object).getValue() == this.getValue());
|
||||
return object instanceof Media other &&
|
||||
object.getClass() == this.getClass() &&
|
||||
other.getValue() == this.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,7 +193,7 @@ public abstract class AbstractAction implements Action, Cloneable, Serializable
|
|||
// to change enabled, it would be possible for stack
|
||||
// overflow in the case where a developer implemented setEnabled
|
||||
// in terms of putValue.
|
||||
if (newValue == null || !(newValue instanceof Boolean)) {
|
||||
if (!(newValue instanceof Boolean)) {
|
||||
newValue = false;
|
||||
}
|
||||
oldValue = enabled;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -2394,8 +2394,8 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
|
|||
if (defaultIcon instanceof Accessible) {
|
||||
AccessibleContext ac =
|
||||
((Accessible)defaultIcon).getAccessibleContext();
|
||||
if (ac != null && ac instanceof AccessibleIcon) {
|
||||
return new AccessibleIcon[] { (AccessibleIcon)ac };
|
||||
if (ac instanceof AccessibleIcon ai) {
|
||||
return new AccessibleIcon[] { ai };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -2441,8 +2441,8 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
|
|||
if (!relationSet.contains(AccessibleRelation.MEMBER_OF)) {
|
||||
// get the members of the button group if one exists
|
||||
ButtonModel model = getModel();
|
||||
if (model != null && model instanceof DefaultButtonModel) {
|
||||
ButtonGroup group = ((DefaultButtonModel)model).getGroup();
|
||||
if (model instanceof DefaultButtonModel defaultModel) {
|
||||
ButtonGroup group = defaultModel.getGroup();
|
||||
if (group != null) {
|
||||
// set the target of the MEMBER_OF relation to be
|
||||
// the members of the button group.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1417,8 +1417,8 @@ public class DebugGraphics extends Graphics {
|
|||
Container container = (Container)component;
|
||||
int debugOptions = 0;
|
||||
|
||||
while (container != null && (container instanceof JComponent)) {
|
||||
debugOptions |= info.getDebugOptions((JComponent)container);
|
||||
while (container instanceof JComponent jc) {
|
||||
debugOptions |= info.getDebugOptions(jc);
|
||||
container = container.getParent();
|
||||
}
|
||||
|
||||
|
|
|
@ -2000,11 +2000,10 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
|
|||
// Get the popup
|
||||
Accessible a =
|
||||
JComboBox.this.getUI().getAccessibleChild(JComboBox.this, 0);
|
||||
if (a != null &&
|
||||
a instanceof javax.swing.plaf.basic.ComboPopup) {
|
||||
if (a instanceof javax.swing.plaf.basic.ComboPopup popup) {
|
||||
|
||||
// get the popup list
|
||||
JList<?> list = ((javax.swing.plaf.basic.ComboPopup)a).getList();
|
||||
JList<?> list = popup.getList();
|
||||
|
||||
// return the i-th selection in the popup list
|
||||
AccessibleContext ac = list.getAccessibleContext();
|
||||
|
|
|
@ -878,8 +878,7 @@ public abstract class JComponent extends Container implements Serializable,
|
|||
}
|
||||
// If we are only to paint to a specific child, determine
|
||||
// its index.
|
||||
if (paintingChild != null &&
|
||||
(paintingChild instanceof JComponent) &&
|
||||
if ((paintingChild instanceof JComponent) &&
|
||||
paintingChild.isOpaque()) {
|
||||
for (; i >= 0; i--) {
|
||||
if (getComponent(i) == paintingChild){
|
||||
|
@ -3636,20 +3635,18 @@ public abstract class JComponent extends Container implements Serializable,
|
|||
boolean temporary, boolean focusedWindowChangeAllowed,
|
||||
FocusEvent.Cause cause)
|
||||
{
|
||||
if ((to == null) || !(to instanceof JComponent)) {
|
||||
if (!(to instanceof JComponent target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((from == null) || !(from instanceof JComponent)) {
|
||||
if (!(from instanceof JComponent jFocusOwner)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
JComponent target = (JComponent) to;
|
||||
if (!target.getVerifyInputWhenFocusTarget()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
JComponent jFocusOwner = (JComponent)from;
|
||||
InputVerifier iv = jFocusOwner.getInputVerifier();
|
||||
|
||||
if (iv == null) {
|
||||
|
@ -3774,7 +3771,7 @@ public abstract class JComponent extends Container implements Serializable,
|
|||
protected AccessibleContainerHandler() {}
|
||||
public void componentAdded(ContainerEvent e) {
|
||||
Component c = e.getChild();
|
||||
if (c != null && c instanceof Accessible) {
|
||||
if (c instanceof Accessible) {
|
||||
AccessibleJComponent.this.firePropertyChange(
|
||||
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
|
||||
null, c.getAccessibleContext());
|
||||
|
@ -3782,7 +3779,7 @@ public abstract class JComponent extends Container implements Serializable,
|
|||
}
|
||||
public void componentRemoved(ContainerEvent e) {
|
||||
Component c = e.getChild();
|
||||
if (c != null && c instanceof Accessible) {
|
||||
if (c instanceof Accessible) {
|
||||
AccessibleJComponent.this.firePropertyChange(
|
||||
AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
|
||||
c.getAccessibleContext(), null);
|
||||
|
|
|
@ -1233,10 +1233,9 @@ public class JInternalFrame extends JComponent implements
|
|||
@BeanProperty(bound = false, expert = true, description
|
||||
= "Specifies what desktop layer is used.")
|
||||
public void setLayer(Integer layer) {
|
||||
if(getParent() != null && getParent() instanceof JLayeredPane) {
|
||||
if (getParent() instanceof JLayeredPane p) {
|
||||
// Normally we want to do this, as it causes the LayeredPane
|
||||
// to draw properly.
|
||||
JLayeredPane p = (JLayeredPane)getParent();
|
||||
p.setLayer(this, layer.intValue(), p.getPosition(this));
|
||||
} else {
|
||||
// Try to do the right thing
|
||||
|
|
|
@ -1110,8 +1110,8 @@ public class JLabel extends JComponent implements SwingConstants, Accessible
|
|||
if (icon instanceof Accessible) {
|
||||
AccessibleContext ac =
|
||||
((Accessible)icon).getAccessibleContext();
|
||||
if (ac != null && ac instanceof AccessibleIcon) {
|
||||
return new AccessibleIcon[] { (AccessibleIcon)ac };
|
||||
if (ac instanceof AccessibleIcon ai) {
|
||||
return new AccessibleIcon[] { ai };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -2949,21 +2949,21 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
|
|||
// re-set listData listeners
|
||||
if (name.equals("model")) {
|
||||
|
||||
if (oldValue != null && oldValue instanceof ListModel) {
|
||||
((ListModel) oldValue).removeListDataListener(this);
|
||||
if (oldValue instanceof ListModel<?> oldModel) {
|
||||
oldModel.removeListDataListener(this);
|
||||
}
|
||||
if (newValue != null && newValue instanceof ListModel) {
|
||||
((ListModel) newValue).addListDataListener(this);
|
||||
if (newValue instanceof ListModel<?> newModel) {
|
||||
newModel.addListDataListener(this);
|
||||
}
|
||||
|
||||
// re-set listSelectionModel listeners
|
||||
} else if (name.equals("selectionModel")) {
|
||||
|
||||
if (oldValue != null && oldValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) oldValue).removeListSelectionListener(this);
|
||||
if (oldValue instanceof ListSelectionModel oldModel) {
|
||||
oldModel.removeListSelectionListener(this);
|
||||
}
|
||||
if (newValue != null && newValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) newValue).addListSelectionListener(this);
|
||||
if (newValue instanceof ListSelectionModel newModel) {
|
||||
newModel.addListSelectionListener(this);
|
||||
}
|
||||
|
||||
firePropertyChange(
|
||||
|
|
|
@ -1598,7 +1598,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
|
|||
return;
|
||||
}
|
||||
JMenuItem mi = getItem(i);
|
||||
if (mi != null && mi instanceof JMenu) {
|
||||
if (mi instanceof JMenu) {
|
||||
if (mi.isSelected()) {
|
||||
MenuElement[] old =
|
||||
MenuSelectionManager.defaultManager().getSelectedPath();
|
||||
|
|
|
@ -706,9 +706,7 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
|
|||
return false;
|
||||
}
|
||||
|
||||
if (c != null && c instanceof JComponent &&
|
||||
((JComponent)c).processKeyBinding(ks, e, condition, pressed)) {
|
||||
|
||||
if (c instanceof JComponent jc && jc.processKeyBinding(ks, e, condition, pressed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2330,17 +2330,17 @@ public class JOptionPane extends JComponent implements Accessible
|
|||
Vector<Object> values = new Vector<Object>();
|
||||
|
||||
s.defaultWriteObject();
|
||||
// Save the icon, if its Serializable.
|
||||
if(icon != null && icon instanceof Serializable) {
|
||||
// Save the icon, if it's Serializable.
|
||||
if (icon instanceof Serializable) {
|
||||
values.addElement("icon");
|
||||
values.addElement(icon);
|
||||
}
|
||||
// Save the message, if its Serializable.
|
||||
if(message != null && message instanceof Serializable) {
|
||||
// Save the message, if it's Serializable.
|
||||
if (message instanceof Serializable) {
|
||||
values.addElement("message");
|
||||
values.addElement(message);
|
||||
}
|
||||
// Save the treeModel, if its Serializable.
|
||||
// Save the treeModel, if it's Serializable.
|
||||
if(options != null) {
|
||||
ArrayList<Object> serOptions = new ArrayList<Object>();
|
||||
|
||||
|
@ -2354,17 +2354,17 @@ public class JOptionPane extends JComponent implements Accessible
|
|||
values.addElement(arrayOptions);
|
||||
}
|
||||
}
|
||||
// Save the initialValue, if its Serializable.
|
||||
if(initialValue != null && initialValue instanceof Serializable) {
|
||||
// Save the initialValue, if it's Serializable.
|
||||
if (initialValue instanceof Serializable) {
|
||||
values.addElement("initialValue");
|
||||
values.addElement(initialValue);
|
||||
}
|
||||
// Save the value, if its Serializable.
|
||||
if(value != null && value instanceof Serializable) {
|
||||
// Save the value, if it's Serializable.
|
||||
if (value instanceof Serializable) {
|
||||
values.addElement("value");
|
||||
values.addElement(value);
|
||||
}
|
||||
// Save the selectionValues, if its Serializable.
|
||||
// Save the selectionValues, if it's Serializable.
|
||||
if(selectionValues != null) {
|
||||
boolean serialize = true;
|
||||
|
||||
|
@ -2381,14 +2381,13 @@ public class JOptionPane extends JComponent implements Accessible
|
|||
values.addElement(selectionValues);
|
||||
}
|
||||
}
|
||||
// Save the inputValue, if its Serializable.
|
||||
if(inputValue != null && inputValue instanceof Serializable) {
|
||||
// Save the inputValue, if it's Serializable.
|
||||
if (inputValue instanceof Serializable) {
|
||||
values.addElement("inputValue");
|
||||
values.addElement(inputValue);
|
||||
}
|
||||
// Save the initialSelectionValue, if its Serializable.
|
||||
if(initialSelectionValue != null &&
|
||||
initialSelectionValue instanceof Serializable) {
|
||||
// Save the initialSelectionValue, if it's Serializable.
|
||||
if (initialSelectionValue instanceof Serializable) {
|
||||
values.addElement("initialSelectionValue");
|
||||
values.addElement(initialSelectionValue);
|
||||
}
|
||||
|
|
|
@ -988,10 +988,9 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
|
|||
JPopupMenu mp = this;
|
||||
while((mp!=null) && (mp.isPopupMenu()!=true) &&
|
||||
(mp.getInvoker() != null) &&
|
||||
(mp.getInvoker().getParent() != null) &&
|
||||
(mp.getInvoker().getParent() instanceof JPopupMenu)
|
||||
(mp.getInvoker().getParent() instanceof JPopupMenu popupMenu)
|
||||
) {
|
||||
mp = (JPopupMenu) mp.getInvoker().getParent();
|
||||
mp = popupMenu;
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
|
@ -1330,13 +1329,13 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
|
|||
Vector<Object> values = new Vector<Object>();
|
||||
|
||||
s.defaultWriteObject();
|
||||
// Save the invoker, if its Serializable.
|
||||
if(invoker != null && invoker instanceof Serializable) {
|
||||
// Save the invoker if != null, (Component implements Serializable)
|
||||
if (invoker != null) {
|
||||
values.addElement("invoker");
|
||||
values.addElement(invoker);
|
||||
}
|
||||
// Save the popup, if its Serializable.
|
||||
if(popup != null && popup instanceof Serializable) {
|
||||
// Save the popup, if it's Serializable.
|
||||
if (popup instanceof Serializable) {
|
||||
values.addElement("popup");
|
||||
values.addElement(popup);
|
||||
}
|
||||
|
|
|
@ -1018,8 +1018,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
|
|||
@SuppressWarnings("rawtypes")
|
||||
Dictionary labelTable = getLabelTable();
|
||||
|
||||
if (labelTable != null && (labelTable instanceof PropertyChangeListener)) {
|
||||
removePropertyChangeListener((PropertyChangeListener) labelTable);
|
||||
if (labelTable instanceof PropertyChangeListener listener) {
|
||||
removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
addPropertyChangeListener( table );
|
||||
|
|
|
@ -6758,11 +6758,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
|||
// re-set tableModel listeners
|
||||
if (name.equals("model")) {
|
||||
|
||||
if (oldValue != null && oldValue instanceof TableModel) {
|
||||
((TableModel) oldValue).removeTableModelListener(this);
|
||||
if (oldValue instanceof TableModel oldModel) {
|
||||
oldModel.removeTableModelListener(this);
|
||||
}
|
||||
if (newValue != null && newValue instanceof TableModel) {
|
||||
((TableModel) newValue).addTableModelListener(this);
|
||||
if (newValue instanceof TableModel newModel) {
|
||||
newModel.addTableModelListener(this);
|
||||
}
|
||||
|
||||
// re-set selectionModel listeners
|
||||
|
@ -6771,24 +6771,20 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
|||
Object source = e.getSource();
|
||||
if (source == JTable.this) { // row selection model
|
||||
|
||||
if (oldValue != null &&
|
||||
oldValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) oldValue).removeListSelectionListener(this);
|
||||
if (oldValue instanceof ListSelectionModel oldModel) {
|
||||
oldModel.removeListSelectionListener(this);
|
||||
}
|
||||
if (newValue != null &&
|
||||
newValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) newValue).addListSelectionListener(this);
|
||||
if (newValue instanceof ListSelectionModel newModel) {
|
||||
newModel.addListSelectionListener(this);
|
||||
}
|
||||
|
||||
} else if (source == JTable.this.getColumnModel()) {
|
||||
|
||||
if (oldValue != null &&
|
||||
oldValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) oldValue).removeListSelectionListener(this);
|
||||
if (oldValue instanceof ListSelectionModel oldModel) {
|
||||
oldModel.removeListSelectionListener(this);
|
||||
}
|
||||
if (newValue != null &&
|
||||
newValue instanceof ListSelectionModel) {
|
||||
((ListSelectionModel) newValue).addListSelectionListener(this);
|
||||
if (newValue instanceof ListSelectionModel newModel) {
|
||||
newModel.addListSelectionListener(this);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -6799,13 +6795,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
|||
// and column's selection property listener as well
|
||||
} else if (name.equals("columnModel")) {
|
||||
|
||||
if (oldValue != null && oldValue instanceof TableColumnModel) {
|
||||
TableColumnModel tcm = (TableColumnModel) oldValue;
|
||||
if (oldValue instanceof TableColumnModel tcm) {
|
||||
tcm.removeColumnModelListener(this);
|
||||
tcm.getSelectionModel().removeListSelectionListener(this);
|
||||
}
|
||||
if (newValue != null && newValue instanceof TableColumnModel) {
|
||||
TableColumnModel tcm = (TableColumnModel) newValue;
|
||||
if (newValue instanceof TableColumnModel tcm) {
|
||||
tcm.addColumnModelListener(this);
|
||||
tcm.getSelectionModel().addListSelectionListener(this);
|
||||
}
|
||||
|
@ -6813,11 +6807,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
|||
// re-se cellEditor listeners
|
||||
} else if (name.equals("tableCellEditor")) {
|
||||
|
||||
if (oldValue != null && oldValue instanceof TableCellEditor) {
|
||||
((TableCellEditor) oldValue).removeCellEditorListener(this);
|
||||
if (oldValue instanceof TableCellEditor oldEditor) {
|
||||
oldEditor.removeCellEditorListener(this);
|
||||
}
|
||||
if (newValue != null && newValue instanceof TableCellEditor) {
|
||||
((TableCellEditor) newValue).addCellEditorListener(this);
|
||||
if (newValue instanceof TableCellEditor newEditor) {
|
||||
newEditor.addCellEditorListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3127,23 +3127,23 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
|||
Vector<Object> values = new Vector<Object>();
|
||||
|
||||
s.defaultWriteObject();
|
||||
// Save the cellRenderer, if its Serializable.
|
||||
if(cellRenderer != null && cellRenderer instanceof Serializable) {
|
||||
// Save the cellRenderer, if it's Serializable.
|
||||
if (cellRenderer instanceof Serializable) {
|
||||
values.addElement("cellRenderer");
|
||||
values.addElement(cellRenderer);
|
||||
}
|
||||
// Save the cellEditor, if its Serializable.
|
||||
if(cellEditor != null && cellEditor instanceof Serializable) {
|
||||
// Save the cellEditor, if it's Serializable.
|
||||
if (cellEditor instanceof Serializable) {
|
||||
values.addElement("cellEditor");
|
||||
values.addElement(cellEditor);
|
||||
}
|
||||
// Save the treeModel, if its Serializable.
|
||||
if(treeModel != null && treeModel instanceof Serializable) {
|
||||
// Save the treeModel, if it's Serializable.
|
||||
if (treeModel instanceof Serializable) {
|
||||
values.addElement("treeModel");
|
||||
values.addElement(treeModel);
|
||||
}
|
||||
// Save the selectionModel, if its Serializable.
|
||||
if(selectionModel != null && selectionModel instanceof Serializable) {
|
||||
// Save the selectionModel, if it's Serializable.
|
||||
if (selectionModel instanceof Serializable) {
|
||||
values.addElement("selectionModel");
|
||||
values.addElement(selectionModel);
|
||||
}
|
||||
|
@ -5414,14 +5414,12 @@ public class JTree extends JComponent implements Scrollable, Accessible
|
|||
public Rectangle getBounds() {
|
||||
Rectangle r = tree.getPathBounds(path);
|
||||
Accessible parent = getAccessibleParent();
|
||||
if (parent != null) {
|
||||
if (parent instanceof AccessibleJTreeNode) {
|
||||
Point parentLoc = ((AccessibleJTreeNode) parent).getLocationInJTree();
|
||||
if (parentLoc != null && r != null) {
|
||||
r.translate(-parentLoc.x, -parentLoc.y);
|
||||
} else {
|
||||
return null; // not visible!
|
||||
}
|
||||
if (parent instanceof AccessibleJTreeNode treeNode) {
|
||||
Point parentLoc = treeNode.getLocationInJTree();
|
||||
if (parentLoc != null && r != null) {
|
||||
r.translate(-parentLoc.x, -parentLoc.y);
|
||||
} else {
|
||||
return null; // not visible!
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -72,8 +72,8 @@ public class MenuSelectionManager {
|
|||
|
||||
// installing additional listener if found in the AppContext
|
||||
Object o = context.get(SwingUtilities2.MENU_SELECTION_MANAGER_LISTENER_KEY);
|
||||
if (o != null && o instanceof ChangeListener) {
|
||||
msm.addChangeListener((ChangeListener) o);
|
||||
if (o instanceof ChangeListener listener) {
|
||||
msm.addChangeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -928,7 +928,7 @@ public class RepaintManager
|
|||
for (int i = roots.size() - 1; i >= index; i--) {
|
||||
Component c = roots.get(i);
|
||||
for(;;) {
|
||||
if (c == root || c == null || !(c instanceof JComponent)) {
|
||||
if (c == root || !(c instanceof JComponent)) {
|
||||
break;
|
||||
}
|
||||
c = c.getParent();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -454,11 +454,11 @@ public class SpinnerDateModel extends AbstractSpinnerModel implements Serializab
|
|||
* @see #addChangeListener
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
if ((value == null) || !(value instanceof Date)) {
|
||||
if (!(value instanceof Date date)) {
|
||||
throw new IllegalArgumentException("illegal value");
|
||||
}
|
||||
if (!value.equals(this.value.getTime())) {
|
||||
this.value.setTime((Date)value);
|
||||
if (!date.equals(this.value.getTime())) {
|
||||
this.value.setTime(date);
|
||||
fireStateChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -452,11 +452,11 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ
|
|||
* @see SpinnerModel#addChangeListener
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
if ((value == null) || !(value instanceof Number)) {
|
||||
if (!(value instanceof Number number)) {
|
||||
throw new IllegalArgumentException("illegal value");
|
||||
}
|
||||
if (!value.equals(this.value)) {
|
||||
this.value = (Number)value;
|
||||
if (!number.equals(this.value)) {
|
||||
this.value = number;
|
||||
fireStateChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2054,8 +2054,8 @@ public class SwingUtilities implements SwingConstants
|
|||
* ImageIcon, and the image it contains is the same as <code>image</code>.
|
||||
*/
|
||||
static boolean doesIconReferenceImage(Icon icon, Image image) {
|
||||
Image iconImage = (icon != null && (icon instanceof ImageIcon)) ?
|
||||
((ImageIcon)icon).getImage() : null;
|
||||
Image iconImage = (icon instanceof ImageIcon i) ?
|
||||
i.getImage() : null;
|
||||
return (iconImage == image);
|
||||
}
|
||||
|
||||
|
|
|
@ -1272,9 +1272,9 @@ public class TransferHandler implements Serializable {
|
|||
// If the Drop target is inactive the dragExit will not be dispatched to the dtListener,
|
||||
// so make sure that we clean up the dtListener anyway.
|
||||
DropTargetListener dtListener = getDropTargetListener();
|
||||
if (dtListener != null && dtListener instanceof DropHandler) {
|
||||
((DropHandler)dtListener).cleanup(false);
|
||||
}
|
||||
if (dtListener instanceof DropHandler dropHandler) {
|
||||
dropHandler.cleanup(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ public class EventListenerList implements Serializable {
|
|||
for (int i = 0; i < lList.length; i+=2) {
|
||||
Class<?> t = (Class)lList[i];
|
||||
EventListener l = (EventListener)lList[i+1];
|
||||
if ((l!=null) && (l instanceof Serializable)) {
|
||||
if (l instanceof Serializable) {
|
||||
s.writeObject(t.getName());
|
||||
s.writeObject(l);
|
||||
}
|
||||
|
|
|
@ -569,10 +569,7 @@ public class BasicDesktopPaneUI extends DesktopPaneUI {
|
|||
if (cycleRoot != null) {
|
||||
FocusTraversalPolicy policy =
|
||||
cycleRoot.getFocusTraversalPolicy();
|
||||
if (policy != null && policy instanceof
|
||||
SortingFocusTraversalPolicy) {
|
||||
SortingFocusTraversalPolicy sPolicy =
|
||||
(SortingFocusTraversalPolicy)policy;
|
||||
if (policy instanceof SortingFocusTraversalPolicy sPolicy) {
|
||||
boolean idc = sPolicy.getImplicitDownCycleTraversal();
|
||||
try {
|
||||
sPolicy.setImplicitDownCycleTraversal(false);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -578,9 +578,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
|||
* @param c the new north pane
|
||||
*/
|
||||
public void setNorthPane(JComponent c) {
|
||||
if (northPane != null &&
|
||||
northPane instanceof BasicInternalFrameTitlePane) {
|
||||
((BasicInternalFrameTitlePane)northPane).uninstallListeners();
|
||||
if (northPane instanceof BasicInternalFrameTitlePane tp) {
|
||||
tp.uninstallListeners();
|
||||
}
|
||||
replacePane(northPane, c);
|
||||
northPane = c;
|
||||
|
@ -1614,9 +1613,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
|||
// account the title pane since you are allowed to resize
|
||||
// the frames to the point where just the title pane is visible.
|
||||
Dimension result = new Dimension();
|
||||
if (getNorthPane() != null &&
|
||||
getNorthPane() instanceof BasicInternalFrameTitlePane) {
|
||||
result = new Dimension(getNorthPane().getMinimumSize());
|
||||
if (getNorthPane() instanceof BasicInternalFrameTitlePane tp) {
|
||||
result = new Dimension(tp.getMinimumSize());
|
||||
}
|
||||
Insets i = frame.getInsets();
|
||||
result.width += i.left + i.right;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -297,20 +297,20 @@ public class BasicMenuUI extends BasicMenuItemUI
|
|||
final MenuSelectionManager defaultManager = MenuSelectionManager.defaultManager();
|
||||
if(force) {
|
||||
Container cnt = menu.getParent();
|
||||
if(cnt != null && cnt instanceof JMenuBar) {
|
||||
if (cnt instanceof JMenuBar menuBar) {
|
||||
MenuElement[] me;
|
||||
MenuElement[] subElements;
|
||||
|
||||
subElements = menu.getPopupMenu().getSubElements();
|
||||
if(subElements.length > 0) {
|
||||
me = new MenuElement[4];
|
||||
me[0] = (MenuElement) cnt;
|
||||
me[0] = menuBar;
|
||||
me[1] = menu;
|
||||
me[2] = menu.getPopupMenu();
|
||||
me[3] = subElements[0];
|
||||
} else {
|
||||
me = new MenuElement[3];
|
||||
me[0] = (MenuElement)cnt;
|
||||
me[0] = menuBar;
|
||||
me[1] = menu;
|
||||
me[2] = menu.getPopupMenu();
|
||||
}
|
||||
|
@ -512,10 +512,10 @@ public class BasicMenuUI extends BasicMenuItemUI
|
|||
manager.clearSelectedPath();
|
||||
} else {
|
||||
Container cnt = menu.getParent();
|
||||
if(cnt != null && cnt instanceof JMenuBar) {
|
||||
if (cnt instanceof JMenuBar menuBar) {
|
||||
MenuElement[] me = new MenuElement[2];
|
||||
me[0]=(MenuElement)cnt;
|
||||
me[1]=menu;
|
||||
me[0] = menuBar;
|
||||
me[1] = menu;
|
||||
manager.setSelectedPath(me);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -964,13 +964,10 @@ public class BasicOptionPaneUI extends OptionPaneUI {
|
|||
* the look and feel for based on the value in the inputComponent.
|
||||
*/
|
||||
protected void resetInputValue() {
|
||||
if(inputComponent != null && (inputComponent instanceof JTextField)) {
|
||||
optionPane.setInputValue(((JTextField)inputComponent).getText());
|
||||
|
||||
} else if(inputComponent != null &&
|
||||
(inputComponent instanceof JComboBox)) {
|
||||
optionPane.setInputValue(((JComboBox)inputComponent)
|
||||
.getSelectedItem());
|
||||
if (inputComponent instanceof JTextField textField) {
|
||||
optionPane.setInputValue(textField.getText());
|
||||
} else if (inputComponent instanceof JComboBox<?> comboBox) {
|
||||
optionPane.setInputValue(comboBox.getSelectedItem());
|
||||
} else if(inputComponent != null) {
|
||||
optionPane.setInputValue(((JList)inputComponent)
|
||||
.getSelectedValue());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -197,8 +197,8 @@ public class BasicSpinnerUI extends SpinnerUI
|
|||
spinner.addChangeListener(getHandler());
|
||||
}
|
||||
JComponent editor = spinner.getEditor();
|
||||
if (editor != null && editor instanceof JSpinner.DefaultEditor) {
|
||||
JTextField tf = ((JSpinner.DefaultEditor)editor).getTextField();
|
||||
if (editor instanceof JSpinner.DefaultEditor defaultEditor) {
|
||||
JTextField tf = defaultEditor.getTextField();
|
||||
if (tf != null) {
|
||||
tf.addFocusListener(nextButtonHandler);
|
||||
tf.addFocusListener(previousButtonHandler);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -344,7 +344,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
|
|||
|
||||
Border b = divider.getBorder();
|
||||
|
||||
if (b == null || !(b instanceof UIResource)) {
|
||||
if (!(b instanceof UIResource)) {
|
||||
divider.setBorder(UIManager.getBorder("SplitPaneDivider.border"));
|
||||
}
|
||||
|
||||
|
@ -2359,8 +2359,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
|
|||
}
|
||||
|
||||
private Component getFirstAvailableComponent(Component c) {
|
||||
if (c!=null && c instanceof JSplitPane) {
|
||||
JSplitPane sp = (JSplitPane)c;
|
||||
if (c instanceof JSplitPane sp) {
|
||||
Component left = getFirstAvailableComponent(sp.getLeftComponent());
|
||||
if (left != null) {
|
||||
c = left;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -535,13 +535,11 @@ public class BasicTableHeaderUI extends TableHeaderUI {
|
|||
* to ensure that the newly selected column is visible.
|
||||
*/
|
||||
private void scrollToColumn(int col) {
|
||||
Container container;
|
||||
JTable table;
|
||||
|
||||
//Test whether the header is in a scroll pane and has a table.
|
||||
if ((header.getParent() == null) ||
|
||||
((container = header.getParent().getParent()) == null) ||
|
||||
!(container instanceof JScrollPane) ||
|
||||
!(header.getParent().getParent() instanceof JScrollPane) ||
|
||||
((table = header.getTable()) == null)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -933,24 +933,21 @@ public class BasicTableUI extends TableUI
|
|||
// the table, seems to have no effect.
|
||||
|
||||
Component editorComp = table.getEditorComponent();
|
||||
if (table.isEditing() && editorComp != null) {
|
||||
if (editorComp instanceof JComponent) {
|
||||
JComponent component = (JComponent)editorComp;
|
||||
map = component.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
Object binding = (map != null) ? map.get(keyStroke) : null;
|
||||
if (binding == null) {
|
||||
map = component.getInputMap(JComponent.
|
||||
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
binding = (map != null) ? map.get(keyStroke) : null;
|
||||
}
|
||||
if (binding != null) {
|
||||
ActionMap am = component.getActionMap();
|
||||
Action action = (am != null) ? am.get(binding) : null;
|
||||
if (action != null && SwingUtilities.
|
||||
if (table.isEditing() && editorComp instanceof JComponent component) {
|
||||
map = component.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
Object binding = (map != null) ? map.get(keyStroke) : null;
|
||||
if (binding == null) {
|
||||
map = component.getInputMap(JComponent.
|
||||
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
binding = (map != null) ? map.get(keyStroke) : null;
|
||||
}
|
||||
if (binding != null) {
|
||||
ActionMap am = component.getActionMap();
|
||||
Action action = (am != null) ? am.get(binding) : null;
|
||||
if (action != null && SwingUtilities.
|
||||
notifyAction(action, keyStroke, e, component,
|
||||
e.getModifiers())) {
|
||||
e.consume();
|
||||
}
|
||||
e.getModifiers())) {
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1485,8 +1482,8 @@ public class BasicTableUI extends TableUI
|
|||
Container parent = SwingUtilities.getUnwrappedParent(table); // should be viewport
|
||||
if (parent != null) {
|
||||
parent = parent.getParent(); // should be the scrollpane
|
||||
if (parent != null && parent instanceof JScrollPane) {
|
||||
LookAndFeel.installBorder((JScrollPane)parent, "Table.scrollPaneBorder");
|
||||
if (parent instanceof JScrollPane scrollPane) {
|
||||
LookAndFeel.installBorder(scrollPane, "Table.scrollPaneBorder");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,8 +182,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
|||
String prefix = getPropertyPrefix();
|
||||
Object o = DefaultLookup.get(editor, this,
|
||||
prefix + ".keyBindings");
|
||||
if ((o != null) && (o instanceof JTextComponent.KeyBinding[])) {
|
||||
JTextComponent.KeyBinding[] bindings = (JTextComponent.KeyBinding[]) o;
|
||||
if (o instanceof JTextComponent.KeyBinding[] bindings) {
|
||||
JTextComponent.loadKeymap(map, bindings, getComponent().getActions());
|
||||
}
|
||||
}
|
||||
|
@ -536,8 +535,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
|||
* should allow Tab to keyboard - accessibility
|
||||
*/
|
||||
EditorKit editorKit = getEditorKit(editor);
|
||||
if ( editorKit != null
|
||||
&& editorKit instanceof DefaultEditorKit) {
|
||||
if (editorKit instanceof DefaultEditorKit) {
|
||||
Set<AWTKeyStroke> storedForwardTraversalKeys = editor.
|
||||
getFocusTraversalKeys(KeyboardFocusManager.
|
||||
FORWARD_TRAVERSAL_KEYS);
|
||||
|
@ -617,9 +615,8 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
|
|||
if (getEditorKit(editor) instanceof DefaultEditorKit) {
|
||||
if (map != null) {
|
||||
Object obj = map.get(DefaultEditorKit.insertBreakAction);
|
||||
if (obj != null
|
||||
&& obj instanceof DefaultEditorKit.InsertBreakAction) {
|
||||
Action action = new TextActionWrapper((TextAction)obj);
|
||||
if (obj instanceof DefaultEditorKit.InsertBreakAction breakAction) {
|
||||
Action action = new TextActionWrapper(breakAction);
|
||||
componentMap.put(action.getValue(Action.NAME),action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -654,8 +654,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
|
|||
Container p;
|
||||
for(p = toolBar.getParent() ; p != null && !(p instanceof Window) ;
|
||||
p = p.getParent());
|
||||
if(p != null && p instanceof Window)
|
||||
frame = (Window) p;
|
||||
if (p instanceof Window window)
|
||||
frame = window;
|
||||
}
|
||||
if(floatingToolBar == null) {
|
||||
floatingToolBar = createFloatingWindow(toolBar);
|
||||
|
|
|
@ -1131,10 +1131,8 @@ public class BasicTreeUI extends TreeUI
|
|||
* @return a default cell editor
|
||||
*/
|
||||
protected TreeCellEditor createDefaultCellEditor() {
|
||||
if(currentCellRenderer != null &&
|
||||
(currentCellRenderer instanceof DefaultTreeCellRenderer)) {
|
||||
DefaultTreeCellEditor editor = new DefaultTreeCellEditor
|
||||
(tree, (DefaultTreeCellRenderer)currentCellRenderer);
|
||||
if (currentCellRenderer instanceof DefaultTreeCellRenderer defaultRenderer) {
|
||||
DefaultTreeCellEditor editor = new DefaultTreeCellEditor(tree, defaultRenderer);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
|
|
@ -1142,8 +1142,8 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
if (value != null && value instanceof FileFilter) {
|
||||
setText(((FileFilter)value).getDescription());
|
||||
if (value instanceof FileFilter fileFilter) {
|
||||
setText(fileFilter.getDescription());
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -147,8 +147,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
|
|||
Caret caret = comp.getCaret();
|
||||
if (caret instanceof UIResource) {
|
||||
Object o = style.get(context, prefix + ".caretBlinkRate");
|
||||
if (o != null && o instanceof Integer) {
|
||||
Integer rate = (Integer)o;
|
||||
if (o instanceof Integer rate) {
|
||||
caret.setBlinkRate(rate.intValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -203,9 +203,8 @@ public class SynthTreeUI extends BasicTreeUI
|
|||
TreeCellRenderer renderer = tree.getCellRenderer();
|
||||
DefaultTreeCellEditor editor;
|
||||
|
||||
if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
|
||||
editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
|
||||
renderer);
|
||||
if (renderer instanceof DefaultTreeCellRenderer defaultRenderer) {
|
||||
editor = new SynthTreeCellEditor(tree, defaultRenderer);
|
||||
}
|
||||
else {
|
||||
editor = new SynthTreeCellEditor(tree, null);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1150,9 +1150,9 @@ public class BoxView extends CompositeView {
|
|||
int index = getViewIndexAtPosition(testPos);
|
||||
if(index != -1) {
|
||||
View v = getView(index);
|
||||
if(v != null && v instanceof CompositeView) {
|
||||
return ((CompositeView)v).flipEastAndWestAtEnds(position,
|
||||
bias);
|
||||
if (v instanceof CompositeView compositeView) {
|
||||
return compositeView.flipEastAndWestAtEnds(position,
|
||||
bias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -438,11 +438,11 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
|
|||
*/
|
||||
public void setLogicalStyle(int pos, Style s) {
|
||||
Element paragraph = getParagraphElement(pos);
|
||||
if ((paragraph != null) && (paragraph instanceof AbstractElement)) {
|
||||
if (paragraph instanceof AbstractElement abstractElement) {
|
||||
try {
|
||||
writeLock();
|
||||
StyleChangeUndoableEdit edit = new StyleChangeUndoableEdit((AbstractElement)paragraph, s);
|
||||
((AbstractElement)paragraph).setResolveParent(s);
|
||||
StyleChangeUndoableEdit edit = new StyleChangeUndoableEdit(abstractElement, s);
|
||||
abstractElement.setResolveParent(s);
|
||||
int p0 = paragraph.getStartOffset();
|
||||
int p1 = paragraph.getEndOffset();
|
||||
DefaultDocumentEvent e =
|
||||
|
|
|
@ -3302,8 +3302,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
|
|||
|
||||
// Fixes bug 4487492
|
||||
Document doc = JTextComponent.this.getDocument();
|
||||
if (doc != null && doc instanceof StyledDocument) {
|
||||
StyledDocument sDoc = (StyledDocument)doc;
|
||||
if (doc instanceof StyledDocument sDoc) {
|
||||
int offset = startIndex;
|
||||
int length = endIndex - startIndex;
|
||||
sDoc.setCharacterAttributes(offset, length, as, true);
|
||||
|
|
|
@ -370,8 +370,8 @@ class AccessibleHTML implements Accessible {
|
|||
*/
|
||||
public Accessible getAccessibleChild(int i) {
|
||||
ElementInfo childInfo = elementInfo.getChild(i);
|
||||
if (childInfo != null && childInfo instanceof Accessible) {
|
||||
return (Accessible)childInfo;
|
||||
if (childInfo instanceof Accessible accessibleChild) {
|
||||
return accessibleChild;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -1212,9 +1212,8 @@ class AccessibleHTML implements Accessible {
|
|||
private String getText(int offset, int length)
|
||||
throws BadLocationException {
|
||||
|
||||
if (model != null && model instanceof StyledDocument) {
|
||||
StyledDocument doc = (StyledDocument)model;
|
||||
return model.getText(offset, length);
|
||||
if (model instanceof StyledDocument doc) {
|
||||
return doc.getText(offset, length);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1608,8 +1608,8 @@ public class CSS implements Serializable {
|
|||
if (key instanceof HTML.Tag) {
|
||||
HTML.Tag tag = (HTML.Tag)key;
|
||||
Object o = htmlAttrSet.getAttribute(tag);
|
||||
if (o != null && o instanceof AttributeSet) {
|
||||
translateAttributes(tag, (AttributeSet)o, cssAttrSet);
|
||||
if (o instanceof AttributeSet as) {
|
||||
translateAttributes(tag, as, cssAttrSet);
|
||||
}
|
||||
} else if (key instanceof CSS.Attribute) {
|
||||
cssAttrSet.addAttribute(key, htmlAttrSet.getAttribute(key));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -72,16 +72,16 @@ class HRuleView extends View {
|
|||
|
||||
noshade = (String)eAttr.getAttribute(HTML.Attribute.NOSHADE);
|
||||
Object value = eAttr.getAttribute(HTML.Attribute.SIZE);
|
||||
if (value != null && (value instanceof String)) {
|
||||
if (value instanceof String s) {
|
||||
try {
|
||||
size = Integer.parseInt((String)value);
|
||||
size = Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
size = 1;
|
||||
}
|
||||
}
|
||||
value = attr.getAttribute(CSS.Attribute.WIDTH);
|
||||
if (value != null && (value instanceof CSS.LengthValue)) {
|
||||
widthValue = (CSS.LengthValue)value;
|
||||
if (value instanceof CSS.LengthValue lv) {
|
||||
widthValue = lv;
|
||||
}
|
||||
topMargin = getLength(CSS.Attribute.MARGIN_TOP, attr);
|
||||
bottomMargin = getLength(CSS.Attribute.MARGIN_BOTTOM, attr);
|
||||
|
|
|
@ -901,8 +901,8 @@ public class HTMLDocument extends DefaultStyledDocument {
|
|||
if (name != null) {
|
||||
Object maps = getProperty(MAP_PROPERTY);
|
||||
|
||||
if (maps != null && (maps instanceof Hashtable)) {
|
||||
return (Map)((Hashtable)maps).get(name);
|
||||
if (maps instanceof Hashtable<?, ?> hashtable) {
|
||||
return (Map) hashtable.get(name);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -841,8 +841,8 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
|
|||
Element elem, AttributeSet attr, int offset,
|
||||
int x, int y) {
|
||||
Object useMap = attr.getAttribute(HTML.Attribute.USEMAP);
|
||||
if (useMap != null && (useMap instanceof String)) {
|
||||
Map m = hdoc.getMap((String)useMap);
|
||||
if (useMap instanceof String s) {
|
||||
Map m = hdoc.getMap(s);
|
||||
if (m != null && offset < hdoc.getLength()) {
|
||||
Rectangle bounds;
|
||||
TextUI ui = html.getUI();
|
||||
|
@ -1467,12 +1467,8 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
|
|||
|
||||
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
|
||||
Container container = getContainer();
|
||||
Container parentContainer;
|
||||
if (container != null
|
||||
&& (container instanceof javax.swing.JEditorPane)
|
||||
&& (parentContainer = container.getParent()) != null
|
||||
&& (parentContainer instanceof javax.swing.JViewport)) {
|
||||
JViewport viewPort = (JViewport)parentContainer;
|
||||
if ((container instanceof JEditorPane)
|
||||
&& (container.getParent() instanceof JViewport viewPort)) {
|
||||
if (cachedViewPort != null) {
|
||||
JViewport cachedObject = cachedViewPort.get();
|
||||
if (cachedObject != null) {
|
||||
|
@ -2387,9 +2383,9 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
|
|||
*/
|
||||
private void doObjectAction(JEditorPane editor, Element elem) {
|
||||
View view = getView(editor, elem);
|
||||
if (view != null && view instanceof ObjectView) {
|
||||
Component comp = ((ObjectView)view).getComponent();
|
||||
if (comp != null && comp instanceof Accessible) {
|
||||
if (view instanceof ObjectView objectView) {
|
||||
Component comp = objectView.getComponent();
|
||||
if (comp instanceof Accessible) {
|
||||
AccessibleContext ac = comp.getAccessibleContext();
|
||||
if (ac != null) {
|
||||
AccessibleAction aa = ac.getAccessibleAction();
|
||||
|
@ -2473,10 +2469,9 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
|
|||
JEditorPane editor = (JEditorPane)c;
|
||||
|
||||
Document d = editor.getDocument();
|
||||
if (d == null || !(d instanceof HTMLDocument)) {
|
||||
if (!(d instanceof HTMLDocument doc)) {
|
||||
return;
|
||||
}
|
||||
HTMLDocument doc = (HTMLDocument)d;
|
||||
|
||||
ElementIterator ei = new ElementIterator(doc);
|
||||
int currentOffset = editor.getCaretPosition();
|
||||
|
|
|
@ -308,9 +308,7 @@ public class HTMLWriter extends AbstractWriter {
|
|||
// If an instance of an UNKNOWN Tag, or an instance of a
|
||||
// tag that is only visible during editing
|
||||
//
|
||||
if (nameTag != null && endTag != null &&
|
||||
(endTag instanceof String) &&
|
||||
endTag.equals("true")) {
|
||||
if (nameTag != null && "true".equals(endTag)) {
|
||||
outputEndTag = true;
|
||||
}
|
||||
|
||||
|
@ -732,8 +730,8 @@ public class HTMLWriter extends AbstractWriter {
|
|||
write('<');
|
||||
write(tag.toString());
|
||||
Object o = attr.getAttribute(tag);
|
||||
if (o != null && o instanceof AttributeSet) {
|
||||
writeAttributes((AttributeSet)o);
|
||||
if (o instanceof AttributeSet as) {
|
||||
writeAttributes(as);
|
||||
}
|
||||
write('>');
|
||||
tags.addElement(tag);
|
||||
|
@ -813,8 +811,8 @@ public class HTMLWriter extends AbstractWriter {
|
|||
write('<');
|
||||
write(t.toString());
|
||||
Object o = tagValues.elementAt(i);
|
||||
if (o != null && o instanceof AttributeSet) {
|
||||
writeAttributes((AttributeSet)o);
|
||||
if (o instanceof AttributeSet as) {
|
||||
writeAttributes(as);
|
||||
}
|
||||
write('>');
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -271,8 +271,7 @@ class HiddenTagView extends EditableView implements DocumentListener {
|
|||
AttributeSet as = getElement().getAttributes();
|
||||
if (as != null) {
|
||||
Object end = as.getAttribute(HTML.Attribute.ENDTAG);
|
||||
if (end != null && (end instanceof String) &&
|
||||
((String)end).equals("true")) {
|
||||
if ("true".equals(end)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -181,12 +181,11 @@ class Map implements Serializable {
|
|||
* from trying to parse one of the numbers null is returned.
|
||||
*/
|
||||
protected static int[] extractCoords(Object stringCoords) {
|
||||
if (stringCoords == null || !(stringCoords instanceof String)) {
|
||||
if (!(stringCoords instanceof String s)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringTokenizer st = new StringTokenizer((String)stringCoords,
|
||||
", \t\n\r");
|
||||
StringTokenizer st = new StringTokenizer(s, ", \t\n\r");
|
||||
int[] retValue = null;
|
||||
int numCoords = 0;
|
||||
|
||||
|
|
|
@ -2211,10 +2211,9 @@ public class StyleSheet extends StyleContext {
|
|||
retIndex--;
|
||||
} else if (as.isDefined(HTML.Attribute.VALUE)) {
|
||||
Object value = as.getAttribute(HTML.Attribute.VALUE);
|
||||
if (value != null &&
|
||||
(value instanceof String)) {
|
||||
if (value instanceof String s) {
|
||||
try {
|
||||
int iValue = Integer.parseInt((String)value);
|
||||
int iValue = Integer.parseInt(s);
|
||||
return retIndex - counter + iValue;
|
||||
}
|
||||
catch (NumberFormatException nfe) {}
|
||||
|
@ -2744,8 +2743,7 @@ public class StyleSheet extends StyleContext {
|
|||
kind of conditional behaviour in the
|
||||
stylesheet.
|
||||
**/
|
||||
if (o != null && o instanceof AttributeSet) {
|
||||
AttributeSet attr = (AttributeSet)o;
|
||||
if (o instanceof AttributeSet attr) {
|
||||
if (attr.getAttribute(HTML.Attribute.HREF) == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ public void writeRTFHeader()
|
|||
updateCharacterAttributes(goat, style, false);
|
||||
|
||||
basis = style.getResolveParent();
|
||||
if (basis != null && basis instanceof Style) {
|
||||
if (basis instanceof Style) {
|
||||
Integer basedOn = styleTable.get(basis);
|
||||
if (basedOn != null) {
|
||||
writeControlWord("sbasedon", basedOn.intValue());
|
||||
|
|
|
@ -1297,8 +1297,8 @@ public class DefaultMutableTreeNode implements Cloneable,
|
|||
Object[] tValues;
|
||||
|
||||
s.defaultWriteObject();
|
||||
// Save the userObject, if its Serializable.
|
||||
if(userObject != null && userObject instanceof Serializable) {
|
||||
// Save the userObject, if it's Serializable.
|
||||
if (userObject instanceof Serializable) {
|
||||
tValues = new Object[2];
|
||||
tValues[0] = "userObject";
|
||||
tValues[1] = userObject;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue