create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / components / SelectableLabel.java
1 package net.sf.openrocket.gui.components;
2
3 import java.awt.Cursor;
4 import java.awt.Dimension;
5
6 import javax.swing.JTextField;
7 import javax.swing.UIManager;
8 import javax.swing.plaf.basic.BasicTextFieldUI;
9
10 public class SelectableLabel extends JTextField {
11
12         public SelectableLabel() {
13                 this("");
14         }
15
16         public SelectableLabel(String text) {
17                 super(text);
18                 
19                 // Set basic UI since GTK l&f doesn't support null border
20                 this.setUI(new BasicTextFieldUI());
21                 
22                 this.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
23                 
24                 this.setEditable(false);
25                 this.setBorder(null);
26                 this.setOpaque(true);
27                 if (UIManager.getColor("Label.foreground") != null)
28                         this.setForeground(UIManager.getColor("Label.foreground"));
29                 if (UIManager.getColor("Label.background") != null)
30                         this.setBackground(UIManager.getColor("Label.background"));
31                 if (UIManager.getFont("Label.font") != null)
32                         this.setFont(UIManager.getFont("Label.font"));
33                 
34         }
35         
36         // The default preferred size is slightly too short, causing it to scroll
37         @Override
38         public Dimension getPreferredSize() {
39                 Dimension dim = super.getPreferredSize();
40                 dim.width += 5;
41                 return dim;
42         }
43
44 }