root / tags / v2_0_0_Build_2050 / applications / appgvSIG / src / org / gvsig / app / gui / utils / FontChooser.java @ 38653
History | View | Annotate | Download (919 Bytes)
1 |
|
---|---|
2 |
package org.gvsig.app.gui.utils; |
3 |
|
4 |
import java.awt.Component; |
5 |
import java.awt.Dialog; |
6 |
import java.awt.Dimension; |
7 |
import java.awt.Font; |
8 |
import java.awt.Toolkit; |
9 |
|
10 |
import org.jfree.ui.FontChooserDialog; |
11 |
|
12 |
|
13 |
|
14 |
public class FontChooser { |
15 |
public static Font showDialog(String title, Font font) { |
16 |
|
17 |
FontChooserDialog dlg = new FontChooserDialog(
|
18 |
(Dialog)null,title, true,font); |
19 |
|
20 |
dlg.pack(); |
21 |
centerComponent(dlg); |
22 |
|
23 |
dlg.setVisible(true);
|
24 |
if( dlg.isCancelled() ) {
|
25 |
return null; |
26 |
} |
27 |
return dlg.getSelectedFont();
|
28 |
} |
29 |
|
30 |
public static void centerComponent(Component comp) { |
31 |
|
32 |
Dimension scr_dim = Toolkit.getDefaultToolkit().getScreenSize(); |
33 |
Dimension comp_dim = comp.getSize();
|
34 |
|
35 |
comp.setLocation( |
36 |
(scr_dim.width - comp_dim.width) / 2,
|
37 |
(scr_dim.height - comp_dim.height) / 2
|
38 |
); |
39 |
} |
40 |
} |