jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1819033 - /jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java
Date Fri, 22 Dec 2017 12:22:46 GMT
Author: fschumacher
Date: Fri Dec 22 12:22:46 2017
New Revision: 1819033

URL: http://svn.apache.org/viewvc?rev=1819033&view=rev
Log:
Check for headless mode when calculating the scroll mode for menus

This is related to r1818946, which makes some tests available in non gui mode.

Bugzilla Id: 61919 and relates to #363 on github

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java?rev=1819033&r1=1819032&r2=1819033&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java Fri Dec 22 12:22:46 2017
@@ -21,6 +21,7 @@ package org.apache.jorphan.gui;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
+import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.DataFlavor;
@@ -152,16 +153,16 @@ public final class GuiUtils {
      * Make menu scrollable
      * @param menu {@link JMenu}
      */
-    public static void makeScrollableMenu(JMenu menu) { 
-        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-        if(menu.getItemCount()>0) {
+    public static void makeScrollableMenu(JMenu menu) {
+        if (menu.getItemCount() > 0 && !GraphicsEnvironment.isHeadless()) {
+            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
             // We use 80% of height
             int maxItems = (int)Math.round(
                     screenSize.getHeight()*0.8/menu.getMenuComponent(0).getPreferredSize().getHeight());
             MenuScroller.setScrollerFor(menu, maxItems, 200);
         }
     }
-    
+
     /**
      * Copy text to clipboard
      * @param text Text to copy



Mime
View raw message