Using GridPane to layout form : GridPane « JavaFX « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » JavaFX » GridPane 




Using GridPane to layout form
 

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Callback;

public class Main extends Application {
  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage stage) {
    stage.setTitle("ComboBoxSample");
    
    Button button = new Button("Send");
    Label notification = new Label();
    TextField subject = new TextField("");
    TextArea text = new TextArea("");
    
    Scene scene = new Scene(new Group()450250);

    ComboBox emailComboBox = new ComboBox();
    ComboBox priorityComboBox = new ComboBox();

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5555));
    grid.add(new Label("To: ")00);
    grid.add(emailComboBox, 10);
    grid.add(new Label("Priority: ")20);
    grid.add(priorityComboBox, 30);
    
    grid.add(new Label("Label: ")40);
    grid.add(new Label("Value")50);
    
    
    grid.add(new Label("Subject: ")01);
    grid.add(subject, 1131);
    grid.add(text, 0241);
    grid.add(button, 03);
    grid.add(notification, 1331);

    Group root = (Groupscene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

  }
}

   
  














Related examples in the same category
1.Using GridPane to layout controls
2.create a GridPane with 5 columns 100 pixels wide
3.GridPane where columns take 25%, 50%, 25% of its width
4.Layout a Login Dialog
5.Percent Height for GridPane Row
6.Create a GridPane with 10 rows 50 pixels tall
7.Login window
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.