create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / components / HtmlLabel.java
1 package net.sf.openrocket.gui.components;
2
3 import java.awt.Dimension;
4
5 import javax.swing.JLabel;
6
7 /**
8  * A JLabel that limits the minimum and maximum height of the label to the
9  * initial preferred height of the label.  This is required in labels that use HTML
10  * since these often cause the panels to expand too much in height.
11  * 
12  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
13  */
14 public class HtmlLabel extends JLabel {
15
16         public HtmlLabel() {
17                 super();
18                 limitSize();
19         }
20
21         public HtmlLabel(String text) {
22                 super(text);
23                 limitSize();
24         }
25
26         public HtmlLabel(String text, int horizontalAlignment) {
27                 super(text, horizontalAlignment);
28                 limitSize();
29         }
30         
31         
32         private void limitSize() {
33                 Dimension dim = this.getPreferredSize();
34                 this.setMinimumSize(new Dimension(0, dim.height));
35                 this.setMaximumSize(new Dimension(Integer.MAX_VALUE, dim.height));
36         }
37
38 }