1 package net.sf.openrocket.gui.components;
3 import java.awt.Cursor;
4 import java.awt.Dimension;
6 import javax.swing.JTextField;
7 import javax.swing.UIManager;
8 import javax.swing.plaf.basic.BasicTextFieldUI;
10 public class SelectableLabel extends JTextField {
12 public SelectableLabel() {
16 public SelectableLabel(String text) {
19 // Set basic UI since GTK l&f doesn't support null border
20 this.setUI(new BasicTextFieldUI());
22 this.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
24 this.setEditable(false);
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"));
36 // The default preferred size is slightly too short, causing it to scroll
38 public Dimension getPreferredSize() {
39 Dimension dim = super.getPreferredSize();