14.JavaFx FlowPane 流式布局

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

import java.util.ArrayList;
import java.util.List;

/**
 * FlowPane 流式布局
 */
public class Demo16 extends Application {

    @Override
    public void start(Stage stage) throws Exception {

        List<Button> buttonList = new ArrayList<>();
        Button button;
        for (int i = 1; i <= 8; i++) {
            button = new Button("button" + i);
            buttonList.add(button);
        }

        // 流式布局
        FlowPane flowPane = new FlowPane();
        flowPane.setStyle("-fx-background-color: #EE6AA7");
        flowPane.getChildren().addAll(buttonList);
        flowPane.setPadding(new Insets(10));
//        FlowPane.setMargin(buttonList.get(0), new Insets(10));
        flowPane.setAlignment(Pos.CENTER);
        // 水平间距
        flowPane.setHgap(10);
        // 垂直间距
        flowPane.setVgap(10);
        // 垂直排列
        flowPane.setOrientation(Orientation.VERTICAL);
        // 水平排列
        flowPane.setOrientation(Orientation.HORIZONTAL);

        Scene scene = new Scene(flowPane);
        stage.setScene(scene);
        stage.setTitle("javafx");
        stage.setWidth(800);
        stage.setHeight(800);
        stage.show();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Learn the Fundamentals of JavaFX 8 from Programming Guru Herb Schildt Introducing JavaFX 8 Programming provides a fast-paced, practical introduction to JavaFX, Java’s next-generation GUI programming framework. In this easy-to-read guide, best-selling author Herb Schildt presents the key topics and concepts you’ll need to start developing modern, dynamic JavaFX GUI applications. The book begins with the fundamentals, including the general form of a JavaFX program. You then advance to event handling, controls, images, fonts, layouts, effects, transforms, animations (including 3-D animations), menus, and more. Numerous complete examples are included that put key topics and techniques into action. Designed for Java programmers, the book’s focus is on the JavaFX API and all examples are written entirely in Java. Best of all, the book is written in the clear, crisp, uncompromising style that has made Herb Schildt the choice of millions worldwide. Learn the general form of a JavaFX program Work with scenes and stages Understand the fundamentals of JavaFX event handling Explore several controls, such as buttons, list views, sliders, trees, tables, scroll panes, and more Work with images, fonts, and layouts Explore the JavaFX menu system Use visual effects and transforms Incorporate 2-D and 3-D animation Present data in JavaFX charts Display Web-based content using WebView and WebEngine Table of Contents Chapter 1 JavaFX Fundamentals Chapter 2 Introducing Events and Controls Chapter 3 Exploring JavaFX Controls, Part One Chapter 4 Exploring JavaFX Controls, Part Two Chapter 5 Work with Images, Fonts, and Layouts Chapter 6 Effects and Transforms Chapter 7 Animation Chapter 8 Explore Menus Chapter 9 Charts, WebView, and Canvas

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值