document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import javafx.application.Application;
  2. import javafx.scene.Scene;
  3. import javafx.scene.control.Button;
  4. import javafx.scene.control.ListView;
  5. import javafx.scene.layout.AnchorPane;
  6.  
  7. import javafx.stage.Stage;
  8.  
  9. /**
  10.  *
  11.  * @web http://zoranpavlovic.blogspot.com/
  12.  */
  13. public class AnchorPaneMain extends Application {
  14.  
  15.     /**
  16.      * @param args
  17.      *            the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.         launch(args);
  21.     }
  22.  
  23.     @Override
  24.     public void start(Stage primaryStage) {
  25.         primaryStage.setTitle("AnchorPane");
  26.  
  27.         AnchorPane anchorpane = new AnchorPane();
  28.         // List should stretch as anchorpane is resized
  29.         ListView list = new ListView();
  30.         AnchorPane.setTopAnchor(list, 10.0);
  31.         AnchorPane.setLeftAnchor(list, 10.0);
  32.         AnchorPane.setRightAnchor(list, 85.0);
  33.         AnchorPane.setBottomAnchor(list, 10.0);
  34.        
  35.         // Buttons will float on right edge
  36.         Button button1 = new Button("Button1");
  37.         AnchorPane.setTopAnchor(button1, 10.0);
  38.         AnchorPane.setRightAnchor(button1, 10.0);
  39.         Button button2 = new Button("Button2");
  40.         AnchorPane.setTopAnchor(button2, 40.0);
  41.         AnchorPane.setRightAnchor(button2, 10.0);
  42.         //Add list and buttons to AnchorPane
  43.         anchorpane.getChildren().addAll(list, button1, button2);
  44.  
  45.         // Adding AnchorPane to the Scene
  46.         Scene scene = new Scene(anchorpane);
  47.         primaryStage.setScene(scene);
  48.         primaryStage.show();
  49.     }
  50. }
');