當前位置: 首頁>>代碼示例>>Java>>正文


Java Stage.centerOnScreen方法代碼示例

本文整理匯總了Java中javafx.stage.Stage.centerOnScreen方法的典型用法代碼示例。如果您正苦於以下問題:Java Stage.centerOnScreen方法的具體用法?Java Stage.centerOnScreen怎麽用?Java Stage.centerOnScreen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.stage.Stage的用法示例。


在下文中一共展示了Stage.centerOnScreen方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openHelp

import javafx.stage.Stage; //導入方法依賴的package包/類
@FXML
public void openHelp(ActionEvent event) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/helpPopup.fxml"));
    final Scene scene = new Scene(root);
    final Stage stage = new Stage();
    stage.setTitle("Help");
    stage.setScene(scene);
    stage.show();
    stage.setResizable(false);
    stage.centerOnScreen();

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.close();
            }
        }
    });
}
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:21,代碼來源:searchLugController.java

示例2: 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);
            }
        }
    });
}
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:22,代碼來源:statisticsController.java

示例3: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage aPrimaryStage) throws Exception {
	
	FxMediaCatalog mediaCatalog = new FxMediaCatalog();
	Scene scene = new Scene(mediaCatalog, mediaCatalog.getFormMinResolution().getWidth(), mediaCatalog.getFormMinResolution().getHeight());
	aPrimaryStage.setTitle(FxMediaCatalogDemo.class.getSimpleName());
	aPrimaryStage.setScene(scene);
	aPrimaryStage.setMinWidth(mediaCatalog.getFormMinResolution().getWidth());
	aPrimaryStage.setMinHeight(mediaCatalog.getFormMinResolution().getHeight());
	aPrimaryStage.sizeToScene();
	aPrimaryStage.centerOnScreen();
	aPrimaryStage.show();
	//
	//mediaCatalog.getModel().onDeleteMedia().set(tagsItem -> { System.out.println("OnDeleteMedia: " + tagsItem); throw new RuntimeException("RE 123");});
	mediaCatalog.getModel().setCatalogLocation(getCatalogLocation());
	TreeItem<TagsItem> rootItem = mediaCatalog.getModel().getRootItem();
	rootItem.setValue(new TagsItem("ABC", "Media Item 1", "Media 1", "Description AAA"));
	TreeItem<TagsItem> childItem = new TreeItem<TagsItem>(new TagsItem("XYZ", "Media Item 2", "Media 2", "Description BBB"));
	rootItem.getChildren().add(childItem);
	childItem.getChildren().add(new TreeItem<TagsItem>(new TagsItem("MNL", "Media Item 3", "Media 3", "Description CCC")));
	//
	System.out.println("Catalog location: " + mediaCatalog.getModel().getCatalogLocation());
}
 
開發者ID:mikelaud,項目名稱:fx-media-catalog,代碼行數:24,代碼來源:FxMediaCatalogDemo.java

示例4: loadImageArchiveEditor

import javafx.stage.Stage; //導入方法依賴的package包/類
@FXML
private void loadImageArchiveEditor() {
	try {
		FXMLLoader loader = new FXMLLoader(App.class.getResource("/ImageArchiveUI.fxml"));

		Parent root = loader.load();

		ImageArchiveController controller = loader.getController();

		Stage stage = new Stage();

		controller.setStage(stage);
		stage.setTitle("Image Archive Editor");
		Scene scene = new Scene(root);
		scene.getStylesheets().add(App.class.getResource("/style.css").toExternalForm());
		stage.getIcons().add(new Image(getClass().getResourceAsStream("/icons/app_icon_128.png")));
		stage.setScene(scene);
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.setResizable(false);
		stage.centerOnScreen();
		stage.setTitle("Archive Editor");
		stage.show();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:nshusa,項目名稱:rsam-gui,代碼行數:27,代碼來源:StoreController.java

示例5: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage stage) {
	App.stage = stage;
	try {
		Parent root = FXMLLoader.load(App.class.getResource("/ui/Main.fxml"));
		Scene scene = new Scene(root);
		scene.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
		stage.setTitle("OSRS Data To 317 Converter");		
		stage.centerOnScreen();
		stage.setResizable(false);
		stage.sizeToScene();
		stage.initStyle(StageStyle.UNDECORATED);
		stage.setScene(scene);	
		stage.getIcons().add(new Image(App.class.getResourceAsStream("/icons/icon.png")));
		stage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:nshusa,項目名稱:osrs-data-converter,代碼行數:20,代碼來源:App.java

示例6: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
    LoggingDomain.CONFIG.info("Java version: " + System.getProperty("java.version"));

    CalendarView calendarView = new CalendarView();
    calendarView.setToday(LocalDate.now());
    calendarView.setTime(LocalTime.now());
    calendarView.setShowDeveloperConsole(Boolean.getBoolean("calendarfx.developer"));

    GoogleCalendarAppView appView = new GoogleCalendarAppView(calendarView);
    appView.getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm());

    primaryStage.setTitle("Google Calendar");
    primaryStage.setScene(new Scene(appView));
    primaryStage.setWidth(1400);
    primaryStage.setHeight(950);
    primaryStage.centerOnScreen();
    primaryStage.show();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:20,代碼來源:GoogleCalendarApp.java

示例7: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
    Calendar calendar = new Calendar();
    calendar.setName("Google Calendar");
    calendar.setStyle(Calendar.Style.STYLE2);

    GoogleEntry entry = new GoogleEntry();
    entry.setTitle("Google Entry");
    entry.setCalendar(calendar);
    entry.setLocation("Bogota");

    ObservableList<Calendar> allCalendars = FXCollections.observableArrayList(calendar);

    GoogleEntryPopOverContentPane pane = new GoogleEntryPopOverContentPane(entry, allCalendars);

    primaryStage.setTitle("Google Calendar");
    Scene scene = new Scene(pane, 400, 600);
    scene.getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.sizeToScene();
    primaryStage.centerOnScreen();
    primaryStage.show();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:24,代碼來源:HelloGoogleEntryPopOverContentPane.java

示例8: onResetEmployeePasswordButtonClicked

import javafx.stage.Stage; //導入方法依賴的package包/類
/**
 * Displays the reset password dialog for the currently selected employee.
 *
 * @throws IOException
 */
@FXML
private void onResetEmployeePasswordButtonClicked() throws IOException {
    Stage dialogStage = new Stage();
    FXMLLoader loader = new FXMLLoader(
        getClass().getResource("/fxml/ResetEmployeePasswordDialog.fxml")
    );
    Parent dialogRoot = loader.load();
    Scene resetPasswordDialog = new Scene(dialogRoot);
    dialogStage.getIcons().add(new Image("images/Logo.png"));
    dialogStage.setScene(resetPasswordDialog);
    dialogStage.initModality(Modality.APPLICATION_MODAL);
    dialogStage.initOwner(resetEmployeePasswordButton.getScene().getWindow());
    dialogStage.setResizable(false);
    dialogStage.setTitle("Confirm");
    dialogStage.centerOnScreen();

    ResetEmployeePasswordDialogController c;
    c = (ResetEmployeePasswordDialogController) loader.getController();
    long employeeId = getSelectedEmployee().getId();
    c.setEmployeeId(employeeId);

    dialogStage.show();
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:29,代碼來源:StaffAccountsScreenController.java

示例9: onEditPriceClickedButton

import javafx.stage.Stage; //導入方法依賴的package包/類
@FXML
private void onEditPriceClickedButton() throws IOException {

    Stage editPriceDialogStage = new Stage();
    Parent editPriceDialogRoot = FXMLLoader.load(
            getClass().getResource("/fxml/EditPriceDialog.fxml")
    );
    service = roomTableView.getSelectionModel().getSelectedItem();
    Scene editPriceDialog = new Scene(editPriceDialogRoot);

    editPriceDialogStage.getIcons().add(new Image("images/Logo.png"));
    editPriceDialogStage.setScene(editPriceDialog);
    editPriceDialogStage.initModality(Modality.APPLICATION_MODAL);
    editPriceDialogStage.initOwner(editPriceButton.getScene().getWindow());
    editPriceDialogStage.setResizable(false);
    editPriceDialogStage.setTitle("Edit Price");
    editPriceDialogStage.centerOnScreen();
    editPriceDialogStage.show();

}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:21,代碼來源:EditPricesScreenController.java

示例10: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
    double x = Toolkit.getDefaultToolkit().getScreenSize().width * 0.75;
    double y = Toolkit.getDefaultToolkit().getScreenSize().height * 0.75;
    
    Parent root = FXMLLoader.load(getClass().getResource(GlobalConstants.MAIN_VIEW));
    
    Scene scene = new Scene(root,x,y);
    
    scene.getStylesheets().add(GlobalConstants.CSS);
    stage.setOnCloseRequest(event ->{
        File img = new File(LocalEnvironment.getLocalVar(Local.TMP));
        File[] files = img.listFiles();
        
        if(files != null){
            for(File f : files){
                if(f.getName().endsWith(".jpg") || f.getName().endsWith(".JPG")){
                    try {
                        Files.delete(f.toPath());
                    } catch (IOException ex) {
                        Logger.getLogger(MainApp.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
        System.exit(0);
    });
    
    stage.setMinWidth(x);
    stage.setMinHeight(y);
    stage.setTitle(GlobalConstants.TITLE);
    stage.setScene(scene);
    stage.show();
    stage.centerOnScreen();
}
 
開發者ID:Obsidiam,項目名稱:amelia,代碼行數:36,代碼來源:MainApp.java

示例11: loadIn

import javafx.stage.Stage; //導入方法依賴的package包/類
public void loadIn(Stage stage) {
    try {

        Parent root = resetAndLoad();
        Scene scene = createScene(root);
        stage.setScene(scene);
        setupStage(stage);
        stage.show();
        stage.centerOnScreen();

    } catch (IOException e) {
        throw new LireLabException("Could not resetAndLoad fxml file", e);
    }
}
 
開發者ID:AntonioGabrielAndrade,項目名稱:LIRE-Lab,代碼行數:15,代碼來源:FXML.java

示例12: openHome

import javafx.stage.Stage; //導入方法依賴的package包/類
/**
 *
 * @author shabier
 */
    @FXML
    public void openHome(ActionEvent event) throws IOException {
//        MyJDBC.createTestDatabase("shabo");
        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);
                }
            }
        });
    }
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:27,代碼來源:homepageController.java

示例13: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {

    Platform.setImplicitExit(false);

    Injector.setConfigurationSource(config::getInjectionValue);
    Injector.setLogger(s -> LOG.info(s));
    Injector.setModelOrService(Logger.class, LOG);
    Injector.setModelOrService(HueSenseConfig.class, config);
    Injector.setModelOrService(DBManager.class, dbMan);
    Injector.setModelOrService(DataStore.class, store);
    Injector.setModelOrService(HueComm.class, hue);
    Injector.setModelOrService(LanComm.class, lan);
    Injector.setModelOrService(MailService.class, mailServ);

    ConnectingView connView = new ConnectingView();
    Scene scene = new Scene(connView.getView());
    scene.setFill(Color.WHITE);
    stage.setTitle("HueSense");
    final String uri = Thread.currentThread().getContextClassLoader().getResource("global.css").toExternalForm();
    scene.getStylesheets().add(uri);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.setScene(scene);
    stage.setAlwaysOnTop(true);
    stage.setResizable(false);

    stage.centerOnScreen();
    UIUtils.setIcon(stage);

    stage.show();

    hue.startConnecting();

}
 
開發者ID:dainesch,項目名稱:HueSense,代碼行數:35,代碼來源:Launcher.java

示例14: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
    stage.setTitle(APP_TITLE);
    stage.initStyle(StageStyle.UNDECORATED);
    stage.setResizable(false);
    stage.centerOnScreen();
    Async.setStage(stage);
    Async.setScene(SPLASH_XML);
}
 
開發者ID:codingchili,項目名稱:ethereum-ingest,代碼行數:10,代碼來源:Form.java

示例15: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
    view.setPrimaryStage(primaryStage);

    primaryStage.setTitle("Cassandra client");
    primaryStage.getIcons().add(new Image("cassandra_ico.png"));
    primaryStage.setScene(new Scene(view.getView()));
    primaryStage.setResizable(true);
    primaryStage.centerOnScreen();
    primaryStage.show();

    ((MainController) view.getController()).onWindowLoad();
}
 
開發者ID:Kindrat,項目名稱:cassandra-client,代碼行數:14,代碼來源:CassandraClientGUI.java


注:本文中的javafx.stage.Stage.centerOnScreen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。