-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConcreteMediator.java
More file actions
33 lines (31 loc) · 984 Bytes
/
ConcreteMediator.java
File metadata and controls
33 lines (31 loc) · 984 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
package designpattern.behavioral_pattern.mediator.v1;
public class ConcreteMediator extends Mediator {
//维持对各个同事对象的引用
public Button addButton;
public List list;
public TextBox userNameTextBox;
public ComboBox cb;
//封装同事对象之间的交互
@Override
public void componentChanged(Component c) {
//单击按钮
if (c == addButton) {
System.out.println("--单击增加按钮--");
list.update();
cb.update();
userNameTextBox.update();
}
//从列表框选择客户
else if (c == list) {
System.out.println("--从列表框选择客户--");
cb.select();
userNameTextBox.setText();
}
//从组合框选择客户
else if (c == cb) {
System.out.println("--从组合框选择客户--");
cb.select();
userNameTextBox.setText();
}
}
}