怎样在JavaFX中实现菜单
1个回答
2017-01-18
展开全部
怎样在JavaFX中实现菜单
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.collections.*;
public class FXComboExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage){
stage.setTitle("FX ComboBox Example");
Scene scene = new Scene(new Group(), 400, 300);
ObservableList<String> options = FXCollections.observableArrayList("Option 1","Option 2","Option 3");
ComboBox<String> combo = new ComboBox<>(options);
combo.getSelectionModel().select(0); // [0, options.size())
Group root = (Group)scene.getRoot();
root.getChildren().add(combo);
stage.setScene(scene);
stage.show();
}
}
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.collections.*;
public class FXComboExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage){
stage.setTitle("FX ComboBox Example");
Scene scene = new Scene(new Group(), 400, 300);
ObservableList<String> options = FXCollections.observableArrayList("Option 1","Option 2","Option 3");
ComboBox<String> combo = new ComboBox<>(options);
combo.getSelectionModel().select(0); // [0, options.size())
Group root = (Group)scene.getRoot();
root.getChildren().add(combo);
stage.setScene(scene);
stage.show();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询