blob: 50deab7a8add871c9e551488fd7e535b2e80dd6a (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package com.vaadin.tests.tickets;
import com.vaadin.LegacyApplication;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.server.UserError;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.TextField;
public class Ticket2090 extends LegacyApplication {
Label label = new Label();
Button target = new Button();
LegacyWindow w = new LegacyWindow("#2090");
@Override
public void init() {
setMainWindow(w);
final TextField width = new TextField("Width");
width.setImmediate(true);
final TextField height = new TextField("Height");
height.setImmediate(true);
w.addComponent(width);
w.addComponent(height);
w.addComponent(label);
w.addComponent(target);
height.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
try {
target.setHeight(height.getValue());
height.setComponentError(null);
updateLabel();
} catch (Exception e) {
height.setComponentError(new UserError(e.getMessage()));
}
}
});
width.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
try {
target.setWidth(width.getValue());
width.setComponentError(null);
updateLabel();
} catch (Exception e) {
width.setComponentError(new UserError(e.getMessage()));
}
}
});
}
private void updateLabel() {
label.setValue("width: " + target.getWidth()
+ target.getWidthUnits().getSymbol() + ", height: "
+ target.getHeight() + target.getHeightUnits().getSymbol());
}
}
|