-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInner_anonymous.java
More file actions
54 lines (43 loc) · 1.63 KB
/
Inner_anonymous.java
File metadata and controls
54 lines (43 loc) · 1.63 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
package sample;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Inner_anonymous extends Application {
Button button0;
Button button1;
Button button2;
Button button3;
int counter =0;
@Override
public void start(Stage wherethepartyat){
button0 = new Button();
button1 = new Button();
button2 = new Button();
button3 = new Button();
button0.setText("What will it do?");
button1.setText("What will it do?");
button2.setText("What will it do?");
button3.setText("What will it do?");
// THIS CODE
button2.setOnMouseClicked(w00t ->{ counter++; System.out.println("Somebody successfully clicked button number 2: "+counter+ " times");});
// AND THIS CODE ARE DOING LITERALLY THE EXACT SAME THING
button2.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
counter++;
System.out.println("Somebody successfully clicked button number 2: "+counter+ " times");
}
});
HBox hbox = new HBox();
hbox.getChildren().addAll(button0,button1,button2,button3);
Scene scene = new Scene(hbox, 500, 200);
wherethepartyat.setScene(scene);
wherethepartyat.show();
}
}