From fd1b598ea2007451bb20027c13493df43a9f099a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 9 Nov 2018 12:41:48 +0100 Subject: [PATCH] Show port on status bar only when selected --- app/src/processing/app/EditorLineStatus.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/EditorLineStatus.java b/app/src/processing/app/EditorLineStatus.java index 7d4e80b65..f71dd4573 100644 --- a/app/src/processing/app/EditorLineStatus.java +++ b/app/src/processing/app/EditorLineStatus.java @@ -110,11 +110,17 @@ public class EditorLineStatus extends JComponent { g.drawString(text, scale(6), baseline); g.setColor(messageForeground); - String tmp = I18n.format(tr("{0} on {1}"), name, serialport); - - Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null); - - g.drawString(tmp, size.width - (int) bounds.getWidth() - RESIZE_IMAGE_SIZE, + + String statusText; + if (serialport != null && !serialport.isEmpty()) { + statusText = I18n.format(tr("{0} on {1}"), name, serialport); + } else { + statusText = name; + } + + Rectangle2D bounds = g.getFontMetrics().getStringBounds(statusText, null); + + g.drawString(statusText, size.width - (int) bounds.getWidth() - RESIZE_IMAGE_SIZE, baseline); if (OSUtils.isMacOS()) {