在Java中为按钮添加(内置?)图标?

Leb*_*ode 0 java javafx button javafx-8

我已经提供了一个类,它创建了一个按钮布局,但只有文本内部.我想知道是否还有相应的图标添加到按钮:

        public ShapeButtons(View view){
            String[] buttonLabels = { "Circle", "Rectangle", "Square", "Squiggle", "Polyline" };

            for (String label : buttonLabels) {
                Button button = new Button(label);
                button.setMinWidth(100);
                this.add(button, 0, row);
                row++;
                button.setOnAction(this);
    }
Run Code Online (Sandbox Code Playgroud)

对于按钮的构造函数,我知道有一种方法可以做Button(文本,节点图形),但我似乎无法弄清楚如何做到这一点?

VGR*_*VGR 5

Unicode规范的Geometric Shapes块中有很多字符,还有一些其他块,它们可以帮助您:

String[] buttonLabels = { "\u25cf Circle", "\u25ac Rectangle", "\u25a0 Square", "\u2307 Squiggle", "\u29d6 Polyline" };
Run Code Online (Sandbox Code Playgroud)