本文整理汇总了Java中javafx.stage.Stage类的典型用法代码示例。如果您正苦于以下问题:Java Stage类的具体用法?Java Stage怎么用?Java Stage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Stage类属于javafx.stage包,在下文中一共展示了Stage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openHome
import javafx.stage.Stage; //导入依赖的package包/类
@FXML
public void openHome(ActionEvent event) throws IOException {
Node node = (Node) event.getSource();
final Stage stage = (Stage) node.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
stage.centerOnScreen();
final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
final Scene hScene = new Scene(home);
root.setOnKeyPressed(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
if (ke.getCode() == KeyCode.ESCAPE) {
System.out.println("Key Pressed: " + ke.getCode() + " Made by ShaMaster");
stage.setScene(hScene);
}
}
});
}
示例2: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
VBox root = new VBox();
Label counterLabel = new Label("");
ToggleButton startStopButton = new ToggleButton();
// Multicast the ToggleButton's true/false selected state
Observable<Boolean> selectedStates =
JavaFxObservable.valuesOf(startStopButton.selectedProperty())
.publish()
.autoConnect(2);
// Using switchMap() with ToggleButton's selected state willdrive
// whether to kick off an Observable.interval(),
// or dispose() it by switching to empty Observable
selectedStates.switchMap(selected -> {
if (selected)
return Observable.interval(1,
TimeUnit.MILLISECONDS);
else
return Observable.empty();
}).observeOn(JavaFxScheduler.platform()) // Observe on JavaFX UI thread
.map(Object::toString)
.subscribe(counterLabel::setText);
// Change ToggleButton's text depending on its state
selectedStates.subscribe(selected ->
startStopButton.setText(selected ? "STOP" :
"START")
);
root.getChildren().addAll(counterLabel, startStopButton);
stage.setScene(new Scene(root));
stage.show();
}
示例3: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
try {
Scene scene = new Scene(new LoginView().getView());
scene.getStylesheets().add("css/application.css");
primaryStage.setTitle(Constants.APP_NAME);
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.getIcons().add(Constants.APP_LOGO);
primaryStage.show();
createShortcut();
} catch(Exception e) {
e.printStackTrace();
}
}
示例4: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
GameChooser gameManager = new GameChooser(primaryStage);
primaryStage.setScene(makeScene());
primaryStage.setFullScreenExitHint("");
primaryStage.setFullScreenExitKeyCombination(null);
primaryStage.show();
primaryStage.setFullScreen(true);
Animation myAnimation = makeAnimation(myActor, 100, 200, 100);
// start animation
myAnimation.play();
Animation myAnimation1 = makeAnimation(myActor1, 100, 200, 100);
// start animation
myAnimation1.play();
Animation myAnimation2 = makeAnimation(myActor2,100,240,140);
// start animation
myAnimation2.play();
}
示例5: editDrug
import javafx.stage.Stage; //导入依赖的package包/类
private void editDrug(Drug drug) {
FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("/view/drug/EditDrug.fxml"));
try {
Parent root = fXMLLoader.load();
EditDrugController controller = fXMLLoader.getController();
controller.setDrugId(drug.getId());
controller.taNote.setText(drug.getNote());
controller.tfTradeName.setText(drug.getName());
controller.tfGenericName.setText(drug.getGenricName());
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("Edit Drug");
stage.setScene(new Scene(root));
stage.show();
} catch (IOException ex) {
Logger.getLogger(PatientsController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage rootStage) throws Exception {
rootStage.setMaximized(true);
main = this;
FXMLLoader loader = new FXMLLoader(getClass().getResource("/resources/layouts/main.fxml"));
Parent root = loader.load();
Scene rootScene = new Scene(root);
rootStage.setTitle("Parallator");
rootController = loader.getController();
rootStage.setScene(rootScene);
initMenu(rootStage);
rootStage.show();
rootStage.setOnCloseRequest(event -> {
if (rootController.getFile() == null || !rootController.isEdited()) return;
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setHeaderText("Сохранить перед выходом?");
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
Optional<ButtonType> result = alert.showAndWait();
if (result.isPresent() && result.get() == ButtonType.YES) {
rootController.save();
}
if (result.isPresent() && result.get() == ButtonType.CANCEL) {
event.consume();
}
});
rootScene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
switch (event.getCode()) {
case DOWN:
rootController.down();
break;
case UP:
rootController.up();
break;
}
});
if (MainConfig.getMainConfig().path() != null) rootController.open(new File(MainConfig.getMainConfig().path()));
}
示例7: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("2DTree Demo");
Group root = new Group();
Canvas canvas = new Canvas(XSIZE, YSIZE);
gc = canvas.getGraphicsContext2D();
canvas.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
gc.fillOval(e.getX(), e.getY(), 3, 3);
double[] coords = { e.getX() / XSIZE, e.getY() / YSIZE };
instance.insert(new HyperPoint(coords));
instance.draw();
}
});
root.getChildren().add(canvas);
Scene sc = new Scene(root);
primaryStage.setScene(sc);
primaryStage.show();
}
示例8: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("mainView.fxml"));
Scene scene = new Scene(root, 1280, 720);
initData(primaryStage);
// TODO: inserire l'icona dell'applicazione
// rilascio tutte le risorse allocate prima della chiusura dell'applicazione
primaryStage.setOnCloseRequest(MainController::performCleanUp);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
示例9: remover
import javafx.stage.Stage; //导入依赖的package包/类
public void remover() {
botaoRemover.setOnMouseClicked(e -> {
//CadastroDisciplina c = new CadastroDisciplina();
//Pane telaCadastroDisciplinas;
Stage stage = (Stage) botaoRemover.getScene().getWindow();
RemoverProfessor var = new RemoverProfessor();
try {
//SubmenuProfessor.pane = FXMLLoader.load(SubmenuProfessor.class.getResource("submenuProfessorFXML.fxml"));
//var.getPane().setPrefHeight(560);
//var.getPane().setPrefWidth(600);
//SubmenuProfessor.pane.setCenter(var.getPane());
//SubmenuProfessor.pane.setCenterShape(false);
//stage.setScene(new Scene(SubmenuProfessor.pane));
//stage.setTitle("Menu Professor");
//stage.setResizable(false);
ScreenManager.getInstance().showRemoveProf();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
}
示例10: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
VBox root = new VBox();
ListView<String> listView = new ListView<>();
Button refreshButton = new Button("REFRESH");
JavaFxObservable.actionEventsOf(refreshButton)
.observeOn(Schedulers.io())
.flatMapSingle(a ->
Observable.fromArray(getResponse("https://goo.gl/S0xuOi")
.split("\\r?\\n")
).toList()
).observeOn(JavaFxScheduler.platform())
.subscribe(list ->
listView.getItems().setAll(list));
root.getChildren().addAll(listView, refreshButton);
stage.setScene(new Scene(root));
stage.show();
}
示例11: TemplateBox
import javafx.stage.Stage; //导入依赖的package包/类
public TemplateBox(String name) {
setTitle(name);
initModality(Modality.NONE);
String style = LocalFont.getDefaultFontCSS();
getDialogPane().setStyle(
style
);
Stage stage = (Stage) getDialogPane().getScene().getWindow();
stage.setAlwaysOnTop(checkForceOnTop());
stage.getIcons().add(new Image(App.ICON_URL.toString()));
getDialogPane().getButtonTypes().add(new ButtonType(Main.getString("close"), ButtonBar.ButtonData.CANCEL_CLOSE));
openedDialogs.add(this);
final TemplateBox thisBox = this;
setOnCloseRequest(new EventHandler<DialogEvent>() {
@Override
public void handle(DialogEvent event) {
openedDialogs.remove(thisBox);
for(EventHandler<DialogEvent> handler : handlers){
handler.handle(event);
}
}
});
applyStyle();
}
示例12: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
VBox root = new VBox();
Label label = new Label("");
// Observable with second timer
Observable<String> seconds =
Observable.interval(1, TimeUnit.SECONDS)
.map(i -> i.toString())
.observeOn(JavaFxScheduler.platform());
// Turn Observable into Binding
Binding<String> binding =
JavaFxObserver.toBinding(seconds);
//Bind Label to Binding
label.textProperty().bind(binding);
root.setMinSize(200, 100);
root.getChildren().addAll(label);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
示例13: addRequirement
import javafx.stage.Stage; //导入依赖的package包/类
/**
* Creates a window for adding a new Requirement
*
* @return newly created Requirement
*/
public Requirement addRequirement() throws Exception
{
RequirementController rc = new RequirementController();
// Load in the .fxml file:
FXMLLoader loader = new FXMLLoader(getClass().getResource("/View/Requirement.fxml"));
loader.setController(rc);
Parent root = loader.load();
// Set the scene:
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setScene(new Scene(root, 550, 260));
stage.setTitle("New Requirement");
stage.resizableProperty().setValue(false);
stage.getIcons().add(new Image("file:icon.png"));
stage.showAndWait();
// Handle creation of the Account object:
if (rc.isSuccess())
return rc.getRequirement();
return null;
}
示例14: start
import javafx.stage.Stage; //导入依赖的package包/类
@Override
public void start(final Stage primaryStage) throws IOException, UIInitialisationException {
stage = primaryStage;
primaryStage.setTitle(Hygene.TITLE);
primaryStage.initStyle(StageStyle.UNDECORATED);
progress = new ProgressBar();
final URL resource = getClass().getResource(PRELOADER_VIEW);
final Parent root = FXMLLoader.load(resource);
if (root == null) {
throw new UIInitialisationException("Root of Preloader could not be found.");
}
final Scene rootScene = new Scene(root);
primaryStage.setScene(rootScene);
primaryStage.show();
}
示例15: editClicked
import javafx.stage.Stage; //导入依赖的package包/类
public void editClicked(){
if(lstudname.getText().equals(""))
{
// Nothing selected.
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("No Selection");
alert.setHeaderText("No Lecturer Selected");
alert.setContentText("Please select a Lecturer in the list.");
alert.showAndWait();
}
else
{
try {
new EditLec().start(new Stage());
EditLec.txtid.setText(lstudname.getText());
} catch (Exception e) {
ErrorMessage.display("Launch Error", e.getMessage()+" Application Launch Error");
e.printStackTrace();
}
}
}