1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package se.perfectfools.localizer.gui;
22
23 import java.awt.Component;
24 import java.awt.Dimension;
25 import java.awt.Frame;
26
27 import javax.swing.JScrollPane;
28 import javax.swing.UIManager;
29
30 import com.jgoodies.plaf.FontSizeHints;
31 import com.jgoodies.plaf.LookUtils;
32 import com.jgoodies.plaf.Options;
33
34 /***
35 * <code>GUIHelperMethods</code>
36 *
37 * @author Pål Brattberg <<a href="mailto:pal@eminds.se">pal@eminds.se</a>>
38 * @version $Id: GUIHelperMethods.java,v 1.1 2004/11/13 14:44:18 pal Exp $
39 */
40 public class GUIHelperMethods {
41
42 /***
43 * Creates and returns a <code>JScrollpane</code> that has no border.
44 */
45 public static JScrollPane createStrippedScrollPane(Component c) {
46 JScrollPane scrollPane = new JScrollPane(c);
47 scrollPane.setBorder(null);
48 return scrollPane;
49 }
50
51 /***
52 * Locates the frame on the screen center.
53 */
54 public static void centerOnScreen(Frame frame) {
55 Dimension paneSize = frame.getSize();
56 Dimension screenSize = frame.getToolkit().getScreenSize();
57 frame.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);
58 }
59
60 /***
61 * Configures the UI; tries to set the system look on Mac, <code>ExtWindowsLookAndFeel</code>
62 * on general Windows, and <code>Plastic3DLookAndFeel</code> on Windows XP and all other OS.
63 * <p>
64 *
65 * The JGoodies Swing Suite's <code>ApplicationStarter</code>,<code>ExtUIManager</code>,
66 * and <code>LookChoiceStrategies</code> classes provide a much more fine grained algorithm to
67 * choose and restore a look and theme.
68 */
69 public static void configureUI() {
70 UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);
71 Options.setGlobalFontSizeHints(FontSizeHints.MIXED);
72 Options.setDefaultIconSize(new Dimension(18, 18));
73
74 String lafName = LookUtils.IS_OS_WINDOWS_XP ? Options.getSystemLookAndFeelClassName() : Options
75 .getCrossPlatformLookAndFeelClassName();
76
77 try {
78 UIManager.setLookAndFeel(lafName);
79 } catch (Exception e) {
80 System.err.println("Can't set look & feel:" + e);
81 }
82 }
83 }