-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.java
More file actions
44 lines (29 loc) · 1.11 KB
/
Window.java
File metadata and controls
44 lines (29 loc) · 1.11 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
package DecorateurBouton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Window extends JFrame{
public Window(){
this.setTitle("Decorator");
this.setSize(500, 200);
JPanel pan = new JPanel();
JButton textUpperCaseButton = new TextUpperCaseDecorator(new JButton("TextUpperCase"));
JButton alert = new MyAlertDecorator(new JButton("alert"));
JButton hide = new HideDecorator(new JButton("hide button"));
// Double action
JButton alertAndUpper = new TextUpperCaseDecorator(new MyAlertDecorator(new JButton("alertAndUpper")));
// Double action via décorateur existant
JButton hideAndAlert = new HideDecorator(alert);
hideAndAlert.setText("hideAndAlert");
pan.add(textUpperCaseButton);
pan.add(alert);
pan.add(hide);
pan.add(alertAndUpper);
pan.add(hideAndAlert);
this.setContentPane(pan);
this.setVisible(true);
}
public static void main(String[] args){
new Window();
}
}