如何在JavaFX中创建按钮?
例
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class ButtonExample extends Application {
@Override
public void start(Stage stage) {
//创建一个按钮
Button button = new Button();
//将文本设置为按钮
button.setText("Sample Button");
//设置按钮的位置
button.setTranslateX(150);
button.setTranslateY(60);
//设置舞台
Group root = new Group(button);
Scene scene = new Scene(root, 595, 150, Color.BEIGE);
stage.setTitle("Button Example");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}输出结果
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短