Results 1 to 3 of 3
Thread: center a form
- 07-31-2007, 01:30 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 41
- Rep Power
- 0
- 07-31-2007, 01:56 PM #2
Member
- Join Date
- Jul 2007
- Posts
- 74
- Rep Power
- 0
You are crating the form in HTML/JSP..?
- 08-06-2007, 08:47 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 41
- Rep Power
- 0
This works fine
good luckJava Code:public static void centerFrame(JFrame frame) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Point center = ge.getCenterPoint(); Rectangle bounds = ge.getMaximumWindowBounds(); int w = Math.max(bounds.width/2, Math.min(frame.getWidth(), bounds.width)); int h = Math.max(bounds.height/2, Math.min(frame.getHeight(), bounds.height)); int x = center.x - w/2, y = center.y - h/2; frame.setBounds(x, y, w, h); if (w == bounds.width && h == bounds.height) frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.validate(); }
Similar Threads
-
JFrame at Center Screen
By hiranya in forum AWT / SwingReplies: 8Last Post: 02-11-2010, 04:29 PM -
Center background image
By Floetic in forum AWT / SwingReplies: 1Last Post: 04-24-2008, 05:50 PM -
Help Center Live 2.1.3
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-06-2007, 03:43 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM -
Form Help Pls
By CoOlbOyCoOl in forum NetBeansReplies: 4Last Post: 05-27-2007, 08:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks