Advertisement
Guest User

JavaFX

a guest
Jul 23rd, 2013
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1. package br.com.controlxerox.view;
  2.  
  3. import javafx.application.Application;
  4. import javafx.geometry.Insets;
  5. import javafx.geometry.Pos;
  6. import javafx.scene.Scene;
  7. import javafx.scene.control.Button;
  8. import javafx.scene.control.Label;
  9. import javafx.scene.control.TextField;
  10. import javafx.scene.layout.GridPane;
  11. import javafx.scene.text.Font;
  12. import javafx.scene.text.FontWeight;
  13. import javafx.scene.text.Text;
  14. import javafx.stage.Screen;
  15. import javafx.stage.Stage;
  16. import javafx.stage.StageStyle;
  17.  
  18. public class ControlXeroxGUI extends Application {
  19.  
  20.     private TextField txtAcademicRecord;
  21.     private TextField txtName, txtEmail;
  22.     private TextField txtPeriod, txtQuota;
  23.     private Button btRegistration, btSearch, btEvents;
  24.     private Button btSave;
  25.    
  26.     private Scene scene;
  27.    
  28.     private void initializeComponents() {
  29.                        
  30.         this.txtName = new TextField();
  31.         this.txtEmail = new TextField();       
  32.         this.txtQuota = new TextField();
  33.         this.txtPeriod = new TextField();
  34.         this.txtAcademicRecord = new TextField();
  35.        
  36.         this.btSave = new Button("Salvar");
  37.     }
  38.    
  39.     private void buildRegistrationForm() {
  40.        
  41.         GridPane gridForm = new GridPane();
  42.         gridForm.setAlignment(Pos.CENTER);
  43.         gridForm.setHgap(10);
  44.         gridForm.setVgap(10);
  45.         gridForm.setPadding(new Insets(25, 25, 25, 25));
  46.        
  47.         Text title = new Text("Cadastro de Alunos");
  48.         title.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  49.         gridForm.add(title, 0, 0, 2, 1);
  50.        
  51.         Label lblRa = new Label("R.A.:");
  52.         gridForm.add(lblRa, 0, 1);
  53.         gridForm.add(this.txtAcademicRecord, 1, 1);
  54.        
  55.         Label lblName = new Label("Nome: ");
  56.         gridForm.add(lblName, 2, 1);
  57.         gridForm.add(this.txtName, 3, 1);
  58.        
  59.         Label lblEmail = new Label("Email:");
  60.         gridForm.add(lblEmail, 0, 2);
  61.         gridForm.add(this.txtEmail, 1, 2);
  62.        
  63.         Label lblPeriod = new Label("PerĂ­odo:");
  64.         gridForm.add(lblPeriod, 0, 3);
  65.         gridForm.add(this.txtPeriod, 1, 3);    
  66.         gridForm.add(this.btSave, 0, 4);
  67.        
  68.         this.scene = new Scene(gridForm, 300, 300);
  69.         this.scene.getStylesheets().add(
  70.             ControlXeroxGUI.class.getResource("style/rootPanel.css").toExternalForm());
  71.     }
  72.    
  73.     @Override
  74.     public void start(Stage stage) {
  75.        
  76.         this.initializeComponents();
  77.  
  78.         stage.initStyle(StageStyle.UNDECORATED);
  79.         stage.setTitle("Controle de Xerox - D.A Arquitetura");
  80.         stage.centerOnScreen();
  81.         stage.setHeight(Screen.getPrimary().getBounds().getHeight() / 2);
  82.         stage.setWidth(Screen.getPrimary().getBounds().getWidth() / 2);
  83.        
  84.         this.buildRegistrationForm();
  85.         stage.setScene(this.scene);
  86.             stage.show();
  87.     }
  88.        
  89.     public static void main(String[] args) {
  90.        
  91.         launch(args);
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement