jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1444402 - in /jmeter/trunk/src: core/org/apache/jmeter/gui/util/MenuFactory.java jorphan/org/apache/jorphan/gui/GuiUtils.java
Date Sat, 09 Feb 2013 17:38:47 GMT
Author: pmouawad
Date: Sat Feb  9 17:38:46 2013
New Revision: 1444402

URL: http://svn.apache.org/r1444402
Log:
Bug 54538 - GUI: context menu is too big
Improve based on Screen display
Bugzilla Id: 54538

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

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1444402&r1=1444401&r2=1444402&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Sat Feb  9 17:38:46
2013
@@ -238,10 +238,10 @@ public final class MenuFactory {
 
     public static JMenu makeMenus(String[] categories, String label, String actionCommand)
{
         JMenu addMenu = new JMenu(label);
-        GuiUtils.makeMenuScrollable(addMenu);
         for (int i = 0; i < categories.length; i++) {
             addMenu.add(makeMenu(categories[i], actionCommand));
         }
+        GuiUtils.makeScrollableMenu(addMenu);
         return addMenu;
     }
 
@@ -339,10 +339,10 @@ public final class MenuFactory {
      */
     public static JMenu makeMenu(Collection<MenuInfo> menuInfo, String actionCommand,
String menuName) {
         JMenu menu = new JMenu(menuName);
-        GuiUtils.makeMenuScrollable(menu);
         for (MenuInfo info : menuInfo) {
             menu.add(makeMenuItem(info, actionCommand));
         }
+        GuiUtils.makeScrollableMenu(menu);
         return menu;
     }
 

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=1444402&r1=1444401&r2=1444402&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java Sat Feb  9 17:38:46 2013
@@ -19,6 +19,7 @@
 package org.apache.jorphan.gui;
 
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
@@ -131,7 +132,13 @@ public final class GuiUtils {
      * Make menu scrollable
      * @param menu {@link JMenu}
      */
-    public static void makeMenuScrollable(JMenu menu) {
-        MenuScroller.setScrollerFor(menu, 15, 200);
+    public static void makeScrollableMenu(JMenu menu) { 
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        if(menu.getItemCount()>0) {
+            // We use 80% of height
+            int maxItems = (int)Math.round(
+                    screenSize.getHeight()*0.8/menu.getMenuComponent(0).getPreferredSize().getHeight());
+            MenuScroller.setScrollerFor(menu, maxItems, 200);
+        }
     }
 }



Mime
View raw message