updates for 0.9.4
[debian/openrocket] / src / net / sf / openrocket / gui / components / ResizeLabel.java
1 package net.sf.openrocket.gui.components;
2
3 import java.awt.Font;
4 import javax.swing.JLabel;
5
6 /**
7  * A resizeable JLabel.  The method resizeFont(float) changes the current font size by the
8  * given (positive or negative) amount.  The change is relative to the current font size.
9  * <p>
10  * A nice small text is achievable by  <code>new ResizeLabel("My text", -2);</code>
11  * 
12  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
13  */
14
15 public class ResizeLabel extends JLabel {
16         
17         public ResizeLabel() {
18                 super();
19         }
20         
21         public ResizeLabel(String text) {
22                 super(text);
23         }
24         
25         public ResizeLabel(float size) {
26                 super();
27                 resizeFont(size);
28         }
29         
30         public ResizeLabel(String text, float size) {
31                 super(text);
32                 resizeFont(size);
33         }
34         
35         public ResizeLabel(String text, int horizontalAlignment, float size) {
36                 super(text, horizontalAlignment);
37                 resizeFont(size);
38         }
39         
40         
41         public void resizeFont(float size) {
42                 Font font = this.getFont();
43                 font = font.deriveFont(font.getSize2D()+size);
44                 this.setFont(font);
45         }
46         
47 }