-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDemo.java
More file actions
37 lines (28 loc) · 865 Bytes
/
Demo.java
File metadata and controls
37 lines (28 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JComponent;
import javax.swing.JFrame;
public class Demo extends JFrame {
public Demo() {
super("EditableJLabel Example");
Container content = getContentPane();
// Create the EditableJLabel
EditableJLabel title = new EditableJLabel("Meow");
title.setPreferredSize(new Dimension(150,24));
// Create and dd a listener for chnages in the value of EditableJLabel
ValueChangedListener valueListener = new ValueChangedListener() {
@Override
public void valueChanged(String value, JComponent source) {
Demo.this.setTitle(value);
}
};
title.addValueChangedListener(valueListener);
// Add the EditableJLabel to the content pane
content.add(title);
pack();
setVisible(true);
}
public static void main(String[] args) {
new Demo();
}
}