root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / utils / Frames.java @ 2047
History | View | Annotate | Download (1.66 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-may-2005
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Style - Code Templates
|
6 |
*/
|
7 |
package es.gva.cit.catalogClient.utils; |
8 |
|
9 |
import java.awt.Frame; |
10 |
import java.awt.GraphicsEnvironment; |
11 |
import java.awt.Point; |
12 |
import java.awt.Rectangle; |
13 |
|
14 |
import javax.swing.JDialog; |
15 |
import javax.swing.JFrame; |
16 |
|
17 |
/**
|
18 |
* @author jpiera
|
19 |
*
|
20 |
* TODO To change the template for this generated type comment go to
|
21 |
* Window - Preferences - Java - Code Style - Code Templates
|
22 |
*/
|
23 |
public class Frames { |
24 |
|
25 |
public static void CenterFrame(JFrame frame) { |
26 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
27 |
Point center = ge.getCenterPoint();
|
28 |
Rectangle bounds = ge.getMaximumWindowBounds();
|
29 |
int w = Math.max(bounds.width/2, Math.min(frame.getWidth(), bounds.width)); |
30 |
int h = Math.max(bounds.height/2, Math.min(frame.getHeight(), bounds.height)); |
31 |
int x = center.x - w/2, y = center.y - h/2; |
32 |
frame.setBounds(x, y, w, h); |
33 |
if (w == bounds.width && h == bounds.height)
|
34 |
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
35 |
frame.validate(); |
36 |
} |
37 |
|
38 |
public static void CenterFrame(JDialog frame) { |
39 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
40 |
Point center = ge.getCenterPoint();
|
41 |
Rectangle bounds = ge.getMaximumWindowBounds();
|
42 |
int w = Math.max(bounds.width/2, Math.min(frame.getWidth(), bounds.width)); |
43 |
int h = Math.max(bounds.height/2, Math.min(frame.getHeight(), bounds.height)); |
44 |
int x = center.x - w/2, y = center.y - h/2; |
45 |
frame.setBounds(x, y, w, h); |
46 |
if (w == bounds.width && h == bounds.height)
|
47 |
//frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
48 |
frame.validate(); |
49 |
} |
50 |
} |