Advertisement
ARIELCARRARO

Main.java

Jan 3rd, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. /**
  2. *@author Ariel Carraro
  3. *@date 3 de enero de 2013
  4. *@description Ventana en JavaFX
  5. */
  6.  
  7. package sample;
  8.  
  9. import javafx.application.Application;
  10. import javafx.fxml.FXMLLoader;
  11. import javafx.scene.Parent;
  12. import javafx.scene.Scene;
  13. import javafx.scene.control.Tooltip;
  14. import javafx.stage.Stage;
  15.  
  16. import javafx.event.Event;
  17. import javafx.event.ActionEvent;
  18. import javafx.event.EventHandler;
  19. import javafx.scene.control.Button;
  20. import javafx.scene.layout.StackPane;
  21. import javafx.scene.paint.Color;
  22.  
  23. import javax.swing.*;
  24.  
  25. public class Main extends Application {
  26.  
  27.     private Button boton;
  28.     private StackPane panel;
  29.  
  30.  
  31.     @Override
  32.     public void start(Stage primaryStage) throws Exception{
  33.         Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
  34.  
  35.         panel = new StackPane();
  36.  
  37.         boton = new Button("Activa");
  38.         boton.setVisible(true);
  39.         boton.setOnAction(new EventHandler<ActionEvent>() {
  40.             public void handle(ActionEvent event) {
  41.                 javax.swing.JOptionPane.showMessageDialog(null,"Hola mundo");
  42.             }
  43.         });
  44.  
  45.  
  46.  
  47.         panel.getChildren().add(boton);
  48.  
  49.         Scene escena = new Scene(panel, 250, 150, Color.BLACK);
  50.  
  51.  
  52.         primaryStage.setTitle("Iniciando con Java FX");
  53.         primaryStage.setScene(new Scene(root, 300, 275));
  54.         primaryStage.setScene(escena);
  55.         primaryStage.show();
  56.     }
  57.  
  58.  
  59.     public static void main(String[] args) {
  60.         launch(args);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement