forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitleBar.java
More file actions
executable file
·51 lines (49 loc) · 1.21 KB
/
Copy pathTitleBar.java
File metadata and controls
executable file
·51 lines (49 loc) · 1.21 KB
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
package javaforce.webui;
/** TitleBar to be placed in PopupPanel
*
* @author pquiring
*/
public class TitleBar extends Container {
private Label label;
private Button button;
private Pad pad;
private PopupPanel panel;
private Runnable onClose;
public TitleBar(String title, PopupPanel panel) {
this.panel = panel;
setClass("titlebar");
label = new Label(title);
label.addClass("defaultcursor");
label.addClass("noselect");
label.setColor(Color.white);
add(label);
pad = new Pad();
add(pad);
button = new Button("X");
button.addClass("right");
add(button);
button.addClickListener((e, c) -> {
if (onClose != null) {
onClose.run();
} else {
panel.setVisible(false);
}
});
}
public void init() {
super.init();
addEvent("onmousedown", "onmousedownPopupPanel(event, " + panel.id + ");");
}
public void setOnClose(Runnable onClose) {
this.onClose = onClose;
}
public void setHeight(int h) {
super.setHeight(h);
label.setHeight(h);
button.setWidth(h);
button.setHeight(h);
}
public void setText(String title) {
label.setText(title);
}
}