Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. import javafx.scene.control.Alert.AlertType;
  2. import javafx.scene.control.Label;
  3. import javafx.scene.input.ClipboardContent;
  4. import javafx.scene.input.DataFormat;
  5. import javafx.scene.input.Dragboard;
  6. import javafx.scene.input.TransferMode;
  7. import javafx.scene.layout.Background;
  8. import javafx.scene.layout.BackgroundFill;
  9. import javafx.scene.layout.HBox;
  10. import javafx.scene.paint.Color;
  11.  
  12. import com.gluonhq.charm.glisten.mvc.View;
  13.  
  14. public class MainView extends View {
  15.  
  16. HBox root;
  17.  
  18. public MainView(String name) {
  19. super(name);
  20.  
  21. Label source = new Label("Source");
  22. configureDragSource(source);
  23. Label target = new Label("Target");
  24. configureDragTarget(target);
  25. Label popupTarget = new Label("Popup Target");
  26. configureDragPopupTarget(popupTarget);
  27. root = new HBox(40, source, target, popupTarget);
  28. setCenter(root);
  29. }
  30.  
  31. private void configureDragSource(Label source) {
  32. source.setOnDragDetected(e -> {
  33. root.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));
  34. Dragboard db = source.startDragAndDrop(TransferMode.ANY);
  35. ClipboardContent content = new ClipboardContent();
  36. content.put(DataFormat.PLAIN_TEXT, source.getText());
  37. db.setContent(content);
  38. });
  39. source.setOnDragDone(e -> root.setBackground(new Background(new BackgroundFill(null, null, null))));
  40. }
  41.  
  42. private void configureDragTarget(Label target) {
  43. target.setOnDragOver(e -> e.acceptTransferModes(TransferMode.ANY));
  44.  
  45. }
  46.  
  47. private void configureDragPopupTarget(Label popupTarget) {
  48. popupTarget.setOnDragOver(e -> e.acceptTransferModes(TransferMode.ANY));
  49. popupTarget.setOnDragDropped(e -> {
  50. javafx.scene.control.Alert popup1 = new javafx.scene.control.Alert(AlertType.INFORMATION);
  51. com.gluonhq.charm.glisten.control.Alert popup2 = new com.gluonhq.charm.glisten.control.Alert(AlertType.INFORMATION);
  52. popup1.showAndWait();
  53. });
  54. }
  55. }
  56.  
  57. import com.gluonhq.charm.glisten.application.MobileApplication;
  58.  
  59. public class TestApplication extends MobileApplication {
  60.  
  61. @Override
  62. public void init() {
  63. addViewFactory(HOME_VIEW, () -> new MainView(HOME_VIEW));
  64. }
  65.  
  66. public static void main(String[] args) {
  67. launch(args);
  68. }
  69. }
  70.  
  71. buildscript {
  72. repositories {
  73. jcenter()
  74. }
  75. dependencies {
  76. classpath 'org.javafxports:jfxmobile-plugin:1.3.5'
  77. }
  78. }
  79.  
  80. apply plugin: 'org.javafxports.jfxmobile'
  81. apply plugin: 'eclipse'
  82.  
  83. jar {
  84. manifest {
  85. attributes 'Main-Class': 'com.test.TestApplication'
  86. }
  87. }
  88.  
  89. jfxmobile {
  90. downConfig {
  91. version = '3.3.0'
  92. plugins 'display', 'lifecycle', 'statusbar', 'storage'
  93. }
  94. android {
  95. compileSdkVersion = 19
  96. // manifest = 'src/android/AndroidManifest.xml'
  97. }
  98. ios {
  99. infoPList = file('src/ios/Default-Info.plist')
  100. forceLinkClasses = [
  101. 'com.gluonhq.**.*',
  102. 'javax.annotations.**.*',
  103. 'javax.inject.**.*',
  104. 'javax.json.**.*',
  105. 'org.glassfish.json.**.*'
  106. ]
  107. }
  108. }
  109.  
  110. eclipse {
  111. classpath {
  112. downloadJavadoc = true
  113. downloadSources = true
  114. }
  115. }
  116.  
  117. repositories {
  118. jcenter()
  119. maven {
  120. url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
  121. }
  122. }
  123.  
  124. mainClassName = 'com.test.TestApplication'
  125.  
  126. dependencies {
  127. compile 'com.gluonhq:charm:4.3.5'
  128. }
  129.  
  130. task wrapper(type: Wrapper) {
  131. gradleVersion = '4.2'
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement