| 1 |
package speechrecorder; |
|---|
| 2 |
import java.awt.Container; |
|---|
| 3 |
import java.awt.FlowLayout; |
|---|
| 4 |
|
|---|
| 5 |
import javax.swing.JLabel; |
|---|
| 6 |
import javax.swing.JTextArea; |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
public class MultiLineLabel extends JTextArea { |
|---|
| 10 |
|
|---|
| 11 |
public MultiLineLabel(Container parent, String text, |
|---|
| 12 |
int maxWidth, boolean labelFont) { |
|---|
| 13 |
super(); |
|---|
| 14 |
JLabel lbl = new JLabel(); |
|---|
| 15 |
setFocusable(false); |
|---|
| 16 |
setEditable(false); |
|---|
| 17 |
setBackground(lbl.getBackground()); |
|---|
| 18 |
setLineWrap(true); |
|---|
| 19 |
setWrapStyleWord(true); |
|---|
| 20 |
if (labelFont) { |
|---|
| 21 |
setFont(lbl.getFont()); |
|---|
| 22 |
} |
|---|
| 23 |
setHighlighter(null); |
|---|
| 24 |
if (maxWidth > 0) { |
|---|
| 25 |
|
|---|
| 26 |
setColumns(Math.min(maxWidth, 100)); |
|---|
| 27 |
} |
|---|
| 28 |
append((text == null || text.length() == 0) ? " " : text); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
public MultiLineLabel(Container parent, String text) { |
|---|
| 32 |
this(parent, text, 0, true); |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
public MultiLineLabel(Container parent, String text, boolean labelFont) { |
|---|
| 36 |
this(parent, text, 0, labelFont); |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
public MultiLineLabel(Container parent, String text, int maxWidth) { |
|---|
| 40 |
this(parent, text, maxWidth, true); |
|---|
| 41 |
} |
|---|
| 42 |
} |
|---|