24 package test.scenegraph.app;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.concurrent.ExecutionException;
31 import javafx.collections.FXCollections;
32 import javafx.concurrent.Task;
33 import javafx.event.ActionEvent;
34 import javafx.event.Event;
35 import javafx.event.EventHandler;
36 import javafx.event.EventType;
37 import javafx.geometry.Insets;
38 import javafx.geometry.Orientation;
39 import javafx.scene.Scene;
40 import javafx.scene.control.*;
41 import javafx.scene.input.*;
42 import javafx.scene.layout.BorderPane;
43 import javafx.scene.layout.FlowPane;
44 import javafx.scene.layout.VBoxBuilder;
45 import test.javaclient.shared.InteroperabilityApp;
46 import test.javaclient.shared.Utils;
47
48 /**
49 *
50 * @author Aleksandr Sakharuk
51 */
52 public class SceneEventHandlersApp extends InteroperabilityApp
53 {
54
55 public static void main(String... args)
56 {
57 Utils.launch(SceneEventHandlersApp.class, args);
58 //System.out.println("fx: " + VersionInfo.getRuntimeVersion());
59 }
60
61 @Override
62 protected Scene getScene()
63 {
64 eventCombo.setId(EVENTS_COMBO_ID);
99 public void handle(DragEvent event) {
100 event.acceptTransferModes(TransferMode.COPY);
101 }
102 });
103
104 dropField.setOnDragDropped(new EventHandler<DragEvent>() {
105
106 public void handle(DragEvent event) {
107 Dragboard db = event.getDragboard();
108 boolean success = false;
109 if (db.hasString()) {
110 dropField.setText(db.getString());
111 success = true;
112 }
113 event.setDropCompleted(success);
114 }
115 });
116
117 for(EventTypes t: EventTypes.values())
118 {
119 Label lb = LabelBuilder.create().text(t.toString()).id(t.toString()).style(NOT_HANDLED_STYLE).build();
120 controlLabels.add(lb);
121 }
122
123 BorderPane root = new BorderPane();
124 FlowPane flow = new FlowPane(Orientation.VERTICAL);
125 flow.setVgap(30);
126 flow.setHgap(1);
127 flow.setPadding(new Insets(10, 10, 10, 10));
128 flow.getChildren().addAll(actionButton, dragField, dropField);
129 root.setTop(eventCombo);
130 root.setCenter(flow);
131 root.setLeft(VBoxBuilder.create().children(controlLabels).padding(new Insets(10, 10, 10, 10)).build());
132 scene = new Scene(root);
133
134 scene.addEventHandler(MouseEvent.DRAG_DETECTED, new EventHandler<MouseEvent>() {
135
136 public void handle(MouseEvent arg0) {
137 //System.out.println("startFullDrag handled");
138 scene.startFullDrag();
139 }
140 });
141
142 return scene;
143 }
144
145 public Map<EventType<Event>, Boolean> getResults()
146 {
147 return handled;
148 }
149
150 private ComboBox<EventTypes> eventCombo = new ComboBox<EventTypes>();
151 private Button actionButton = new Button("Action");
|
24 package test.scenegraph.app;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.concurrent.ExecutionException;
31 import javafx.collections.FXCollections;
32 import javafx.concurrent.Task;
33 import javafx.event.ActionEvent;
34 import javafx.event.Event;
35 import javafx.event.EventHandler;
36 import javafx.event.EventType;
37 import javafx.geometry.Insets;
38 import javafx.geometry.Orientation;
39 import javafx.scene.Scene;
40 import javafx.scene.control.*;
41 import javafx.scene.input.*;
42 import javafx.scene.layout.BorderPane;
43 import javafx.scene.layout.FlowPane;
44 import javafx.scene.layout.VBox;
45 import test.javaclient.shared.InteroperabilityApp;
46 import test.javaclient.shared.Utils;
47
48 /**
49 *
50 * @author Aleksandr Sakharuk
51 */
52 public class SceneEventHandlersApp extends InteroperabilityApp
53 {
54
55 public static void main(String... args)
56 {
57 Utils.launch(SceneEventHandlersApp.class, args);
58 //System.out.println("fx: " + VersionInfo.getRuntimeVersion());
59 }
60
61 @Override
62 protected Scene getScene()
63 {
64 eventCombo.setId(EVENTS_COMBO_ID);
99 public void handle(DragEvent event) {
100 event.acceptTransferModes(TransferMode.COPY);
101 }
102 });
103
104 dropField.setOnDragDropped(new EventHandler<DragEvent>() {
105
106 public void handle(DragEvent event) {
107 Dragboard db = event.getDragboard();
108 boolean success = false;
109 if (db.hasString()) {
110 dropField.setText(db.getString());
111 success = true;
112 }
113 event.setDropCompleted(success);
114 }
115 });
116
117 for(EventTypes t: EventTypes.values())
118 {
119 Label lb = new Label(t.toString());
120 lb.setId(t.toString());
121 lb.setStyle(NOT_HANDLED_STYLE);
122 controlLabels.add(lb);
123 }
124
125 BorderPane root = new BorderPane();
126 FlowPane flow = new FlowPane(Orientation.VERTICAL);
127 flow.setVgap(30);
128 flow.setHgap(1);
129 flow.setPadding(new Insets(10, 10, 10, 10));
130 flow.getChildren().addAll(actionButton, dragField, dropField);
131 root.setTop(eventCombo);
132 root.setCenter(flow);
133 VBox temp = new VBox();
134 temp.getChildren().addAll(controlLabels);
135 temp.setPadding(new Insets(10, 10, 10, 10));
136 root.setLeft(temp);
137 scene = new Scene(root);
138
139 scene.addEventHandler(MouseEvent.DRAG_DETECTED, new EventHandler<MouseEvent>() {
140
141 public void handle(MouseEvent arg0) {
142 //System.out.println("startFullDrag handled");
143 scene.startFullDrag();
144 }
145 });
146
147 return scene;
148 }
149
150 public Map<EventType<Event>, Boolean> getResults()
151 {
152 return handled;
153 }
154
155 private ComboBox<EventTypes> eventCombo = new ComboBox<EventTypes>();
156 private Button actionButton = new Button("Action");
|