创建一个按钮
创建 Button 很简单:
Button sampleButton = new Button();
这将创建一个新的 Button,里面没有任何文字或图形。
如果你想用文本创建一个 Button,只需使用以 String 为参数的构造函数(设置 Button 的 textProperty):
Button sampleButton = new Button("Click Me!");
如果你想创建一个带有图形的 Button 或任何其他 Node,请使用以下构造函数:
Button sampleButton = new Button("I have an icon", new ImageView(new Image("icon.png")));