01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2006, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
18: */
19:
20: package edu.umd.cs.findbugs.gui2;
21:
22: import java.awt.Component;
23: import java.awt.Container;
24: import java.io.IOException;
25:
26: import javax.imageio.ImageIO;
27: import javax.swing.JFrame;
28:
29: @SuppressWarnings("serial")
30: public class FBFrame extends JFrame {
31:
32: /**
33: * Sets size of font
34: * @param size
35: */
36: protected void setFontSize(float size) {
37: setFont(this .getFont().deriveFont(size));
38:
39: setFontSizeHelper(this .getComponents(), size);
40: }
41:
42: /*
43: * Helps above method, runs through all components recursively.
44: */
45: protected void setFontSizeHelper(Component[] comps, float size) {
46: if (comps.length <= 0)
47: return;
48:
49: for (Component comp : comps) {
50: comp.setFont(comp.getFont().deriveFont(size));
51: if (comp instanceof Container)
52: setFontSizeHelper(((Container) comp).getComponents(),
53: size);
54: }
55: }
56:
57: @Override
58: public void addNotify() {
59: super .addNotify();
60:
61: try {
62: setIconImage(ImageIO.read(MainFrame.class
63: .getResource("smallBuggy.png")));
64: } catch (IOException e) {
65: Debug.println(e);
66: }
67:
68: setFontSize(Driver.getFontSize());
69: }
70: }
|