< prev index next >

src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -251,13 +251,13 @@
         if (checkIcon != null) {
             paintCheck(g, b, checkIcon, checkIconRect);
         }
 
         // Draw the accelerator first in case the HTML renderer changes the color
-        if (keyString != null && !keyString.equals("")) {
+        if (keyString != null && !keyString.isEmpty()) {
             final int yAccel = acceleratorRect.y + fm.getAscent();
-            if (modifiersString.equals("")) {
+            if (modifiersString.isEmpty()) {
                 // just draw the keyString
                 SwingUtilities2.drawString(c, g, keyString, acceleratorRect.x, yAccel);
             } else {
                 final int modifiers = accelerator.getModifiers();
                 int underlinedChar = 0;

@@ -280,11 +280,11 @@
                 }
             }
         }
 
         // Draw the Text
-        if (text != null && !text.equals("")) {
+        if (text != null && !text.isEmpty()) {
             final View v = (View)c.getClientProperty(BasicHTML.propertyKey);
             if (v != null) {
                 v.paint(g, textRect);
             } else {
                 final int mnemonic = (AquaMnemonicHandler.isMnemonicHidden() ? -1 : model.getMnemonic());

@@ -340,11 +340,11 @@
         r.setBounds(textRect);
         r = SwingUtilities.computeUnion(iconRect.x, iconRect.y, iconRect.width, iconRect.height, r);
         //   r = iconRect.union(textRect);
 
         // Add in the accelerator
-        boolean acceleratorTextIsEmpty = (keyString == null) || keyString.equals("");
+        boolean acceleratorTextIsEmpty = (keyString == null) || keyString.isEmpty();
 
         if (!acceleratorTextIsEmpty) {
             r.width += acceleratorRect.width;
         }
 

@@ -442,11 +442,11 @@
 
     private String layoutMenuItem(final JMenuItem menuItem, final FontMetrics fm, final String text, final FontMetrics fmAccel, String keyString, final String modifiersString, final Icon icon, final Icon checkIcon, final Icon arrowIcon, final int verticalAlignment, final int horizontalAlignment, final int verticalTextPosition, final int horizontalTextPosition, final Rectangle viewR, final Rectangle iconR, final Rectangle textR, final Rectangle acceleratorR, final Rectangle checkIconR, final Rectangle arrowIconR, final int textIconGap, final int menuItemGap) {
         // Force it to do "LEFT", then flip the rects if we're right-to-left
         SwingUtilities.layoutCompoundLabel(menuItem, fm, text, icon, verticalAlignment, SwingConstants.LEFT, verticalTextPosition, horizontalTextPosition, viewR, iconR, textR, textIconGap);
 
-        final boolean acceleratorTextIsEmpty = (keyString == null) || keyString.equals("");
+        final boolean acceleratorTextIsEmpty = (keyString == null) || keyString.isEmpty();
 
         if (acceleratorTextIsEmpty) {
             acceleratorR.width = acceleratorR.height = 0;
             keyString = "";
         } else {
< prev index next >