KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > gui2 > FBDialog


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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 JavaDoc;
23 import java.awt.Container JavaDoc;
24 import java.awt.Dialog JavaDoc;
25 import java.awt.Frame JavaDoc;
26 import java.io.IOException JavaDoc;
27
28 import javax.imageio.ImageIO JavaDoc;
29 import javax.swing.JDialog JavaDoc;
30 import javax.swing.JFrame JavaDoc;
31
32 /**
33  * All Dialogs are FBDialogs so font size will work.
34  * @author Kristin
35  *
36  */

37 @SuppressWarnings JavaDoc("serial")
38 public class FBDialog extends JDialog JavaDoc {
39     
40     public FBDialog(){
41         super(MainFrame.getInstance());
42     }
43     
44     public FBDialog(Frame JavaDoc f){
45         super(f);
46     }
47     
48     public FBDialog(Dialog JavaDoc d){
49         super(d);
50     }
51     
52     /**
53      * Sets size of font
54      * @param size
55      */

56     protected void setFontSize(float size){
57         setFont(this.getFont().deriveFont(size));
58         
59         setFontSizeHelper(this.getComponents(), size);
60     }
61     
62     /*
63      * Helps above method, runs through all components recursively.
64      */

65     protected void setFontSizeHelper(Component JavaDoc[] comps, float size){
66         if(comps.length <= 0)
67             return;
68         
69         for(Component JavaDoc comp : comps){
70             comp.setFont(comp.getFont().deriveFont(size));
71             if(comp instanceof Container JavaDoc)
72                 setFontSizeHelper(((Container JavaDoc)comp).getComponents(), size);
73         }
74     }
75     
76     public void addNotify(){
77         super.addNotify();
78         
79         setFontSize(Driver.getFontSize());
80     }
81     
82 }
Popular Tags