MonologFX最简demo,javafx外用dialog示例

 

参考blog:https://blogs.oracle.com/javajungle/entry/monologfx_floss_javafx_dialogs_for

 1 /*
 2  * To change this template, choose Tools | Templates
 3  * and open the template in the editor.
 4  */
 5 package javafxapplication44;
 6 
 7 import javafx.application.Application;
 8 import javafx.application.Platform;
 9 import javafx.event.ActionEvent;
10 import javafx.event.EventHandler;
11 import javafx.scene.Scene;
12 import javafx.scene.control.Button;
13 import javafx.scene.layout.StackPane;
14 import javafx.stage.Stage;
15 import monologfx.MonologFXButton;
16 import monologfx.MonologFXUtil;
17 
18 public class DialogTest extends Application {
19 
20 private static Object lock = new Object();
21 
22     @Override
23     public void start(Stage primaryStage) {
24         Button btn = new Button();
25         btn.setText("Say 'Hello World'");
26             btn.setOnAction(new EventHandler<ActionEvent>() {
27             @Override
28             public void handle(ActionEvent event) {
29 //                 MonologFXUtil.alert("这里是警告!");    
30                 MonologFXButton.Type type = MonologFXUtil.confirm("你确定吗?");
31                
32                    /* //MonologFXButton.Type取值可以为OK, CANCEL, ABORT, RETRY, IGNORE, YES, NO, CUSTOM1, CUSTOM2, CUSTOM3
33                     if(type == MonologFXButton.Type.OK) { 
34                       // ...do something..
35                     }
36                      
37                   */
38                
39             System.out.println("Hello World!");
40             }
41         });
42 
43     StackPane root = new StackPane();
44     root.getChildren().add(btn);
45 
46     Scene scene = new Scene(root, 300, 250);
47 
48     primaryStage.setTitle("Hello World!");
49     primaryStage.setScene(scene);
50     primaryStage.show();
51 }
52 
53 public static void main(String[] args) {
54 launch(args);
55 }
56 }

 

 效果如图:

 

上面代码显示主要是使用,完整代码请参看

http://down.51cto.com/data/942369

 

 

posted @ 2013-09-10 16:27  君子笑而不语  阅读(1409)  评论(0编辑  收藏  举报