-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageWindow.java
More file actions
61 lines (51 loc) · 1.6 KB
/
MessageWindow.java
File metadata and controls
61 lines (51 loc) · 1.6 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
52
53
54
55
56
57
58
59
60
61
package atChat;
import com.sun.javafx.scene.control.skin.ScrollPaneSkin;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class MessageWindow {
@FXML
private HBox hBox;
@FXML
private ScrollPane scrollPane;
@FXML
private Label msgText;
private Stage thisStage;
protected void setMessage(String msg, Stage thisStage) {
msgText.setText(msg);
this.thisStage = thisStage;
hBox.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (hBox.getHeight() < scrollPane.getHeight()) {
hBox.setMaxHeight(scrollPane.getHeight());
hBox.setMinHeight(scrollPane.getHeight());
hBox.setPrefHeight(scrollPane.getHeight());
}
}
});
thisStage.setOnShown(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
ScrollPaneSkin skin = (ScrollPaneSkin)scrollPane.getSkin();
for (Node node : skin.getChildren()) {
if (node instanceof StackPane) {
((StackPane)node).setCache(false);
}
}
}
});
}
@FXML protected void dismissClick(ActionEvent Event) {
thisStage.close();
}
}