我正在尝试为时区选择创建一个简单的选择框。一切似乎都工作正常,但是choicebox并未下降。
注意:我知道从未调用过某些变量(主要是大多数TimeZones)。我只打了5看看是否是间距问题。
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.TimeZone;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.*;
public class SetupPageTwo {
static String name = null;
public static void display(String title) {
Stage window = new Stage();
VBox layout = new VBox(10);
Scene scene = new Scene(layout);
ChoiceBox<String> timeSelect = new ChoiceBox<>();
TimeZone EST = TimeZone.getTimeZone("EST");
TimeZone HST = TimeZone.getTimeZone("HST");
TimeZone MST = TimeZone.getTimeZone("MST");
TimeZone ACT = TimeZone.getTimeZone("ACT");
TimeZone AET = TimeZone.getTimeZone("AET");
TimeZone AGT = TimeZone.getTimeZone("AGT");
TimeZone ART = TimeZone.getTimeZone("ART");
TimeZone AST = TimeZone.getTimeZone("AST");
TimeZone BET = TimeZone.getTimeZone("BET");
TimeZone BST = TimeZone.getTimeZone("BST");
TimeZone CAT = TimeZone.getTimeZone("CAT");
TimeZone CNT = TimeZone.getTimeZone("CNT");
TimeZone CST = TimeZone.getTimeZone("CST");
TimeZone CTT = TimeZone.getTimeZone("CTT");
TimeZone EAT = TimeZone.getTimeZone("EAT");
TimeZone ECT = TimeZone.getTimeZone("ECT");
TimeZone IET = TimeZone.getTimeZone("IET");
TimeZone IST = TimeZone.getTimeZone("IST");
TimeZone JST = TimeZone.getTimeZone("JST");
TimeZone MIT = TimeZone.getTimeZone("MIT");
TimeZone NET = TimeZone.getTimeZone("NET");
TimeZone NST = TimeZone.getTimeZone("NST");
TimeZone PLT = TimeZone.getTimeZone("PLT");
TimeZone PNT = TimeZone.getTimeZone("PNT");
TimeZone PRT = TimeZone.getTimeZone("PRT");
TimeZone PST = TimeZone.getTimeZone("PST");
TimeZone SST = TimeZone.getTimeZone("SST");
TimeZone VST = TimeZone.getTimeZone("VST");
ObservableList<String> items = FXCollections.observableArrayList();
timeSelect.setItems(items);
items.addAll("EST", "HST", "MST", "ACT", "AET");
timeSelect.show();
timeSelect.setOnAction(e -> {
});
layout.getChildren().add(timeSelect);
layout.setAlignment(Pos.CENTER);
window.setScene(scene);
window.showAndWait();
}
}
我希望ChoiceBox显示所有时区变量。
谢谢!