PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT
ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW
AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE
DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL
BE LOST SOMEWHERE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2936

*** shadow/2936 Tue Jul 31 13:57:58 2001
--- shadow/2936.tmp.13361       Tue Jul 31 13:57:58 2001
***************
*** 0 ****
--- 1,104 ----
+ +============================================================================+
+ | Hardcoded size on frame.                                                   |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 2936                        Product: JMeter                  |
+ |       Status: NEW                         Version: 1.5                     |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Enhancement              OS/Version: Windows 9x              |
+ |     Priority: Other                     Component: Main                    |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                |
+ |  Reported By: [EMAIL PROTECTED]                                             |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ As I saw hardcoded size on the frame I suggest to use this class
+ instead that can set the size and place it in center of another component.
+ 
+ package org.apache.jmeter.gui.util;
+ 
+ import java.awt.Dimension;
+ import java.awt.Component;
+ 
+ /**
+  * This class is a Util for awt Component and could be
+  * used to place them in center of an other.
+  *
+  *
+  * @author  <a href="mailto:[EMAIL PROTECTED]";>Bo Regnlin</a>
+  * @version 1.0
+  */
+ public class ComponentUtil
+ {
+   /**
+                * Use this static method if you want to center
+      * and set its proposion compared to the size of
+      * the current users screen size.
+      * Valid percent is between +-(0-100) minus is treated
+      * as plus, bigger than 100 is always set to 100.
+                *
+                *@param  component The component you want to center and set 
+ size on.
+                *@param  percentOfScreen The percent of the current screensize 
+ you want
+      *        the component to be.
+                */
+   public static void centerComponentInWindow(Component component, int 
+ percentOfScreen)
+   {
+     if(percentOfScreen < 0)
+     {
+       centerComponentInWindow(component, - percentOfScreen);
+       return;
+     }
+     if(percentOfScreen > 100)
+     {
+       centerComponentInWindow(component, 100);
+       return;
+     }
+     double percent = percentOfScreen / 100.d;
+     Dimension dimension = component.getToolkit().getScreenSize();
+     component.setSize((int)(dimension.getWidth()*percent),
+                       (int)(dimension.getHeight()*percent));
+     centerComponentInWindow(component);
+   }
+ 
+   /**
+                * Use this static method if you want to center a component in 
+ Window.
+                *
+                *@param  component The component you want to center in window.
+                */
+   public static void centerComponentInWindow(Component component)
+   {
+     Dimension dimension = component.getToolkit().getScreenSize();
+ 
+     component.setLocation((int)((dimension.getWidth()-component.getWidth())/2),
+                           (int)((dimension.getHeight()-component.getHeight
+ ())/2));
+     component.validate();
+     component.repaint();
+   }
+ 
+   /**
+                * Use this static method if you want to center
+      * a component over an other component.
+                *
+                *@param  parent The component you want to use to place it on.
+                *@param  toBeCentered The component you want to center.
+                */
+   public static void centerComponentInComponent(Component parent, Component 
+ toBeCentered)
+   {
+     toBeCentered.setLocation((int)parent.getX() + (int)((parent.getWidth()-
+ toBeCentered.getWidth())/2),
+                             (int)parent.getY() + (int)((parent.getHeight()-
+ toBeCentered.getHeight())/2));
+   
+     toBeCentered.validate();
+     toBeCentered.repaint();
+   }
+ 
+ }
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to