本文整理匯總了Java中javafx.fxml.FXMLLoader.getController方法的典型用法代碼示例。如果您正苦於以下問題:Java FXMLLoader.getController方法的具體用法?Java FXMLLoader.getController怎麽用?Java FXMLLoader.getController使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.fxml.FXMLLoader
的用法示例。
在下文中一共展示了FXMLLoader.getController方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createControlView
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
private void createControlView(TreeMap... treeMaps) {
Stage stage = new Stage();
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("DataControl.fxml"));
Parent root = loader.load();
DataControlController controller = loader.getController();
for (TreeMap t : treeMaps) {
addTab(t);
controller.addData(t);
}
Scene scene = new Scene(root);
stage.setTitle("FxTreeMap Data control view");
stage.setScene(scene);
} catch (IOException e) {
LOG.log(Level.SEVERE, "Exception while loading control view: {0}", e);
}
stage.show();
stage.setX(stage.getX() + DELTA_SCREEN_POSITION);
stage.setY(stage.getY() + DELTA_SCREEN_POSITION);
}
示例2: openPackageDetails
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public static void openPackageDetails(PackageType pkg, List<CrxPackage> packageList, AuthHandler handler) {
try {
FXMLLoader loader = new FXMLLoader(EpicApp.class.getResource("/fxml/PackageInfo.fxml"));
loader.setResources(ApplicationState.getInstance().getResourceBundle());
loader.load();
PackageInfoController runnerActivityController = loader.getController();
Stage popup = new Stage();
popup.setTitle(pkg.getName() + " (" + pkg.getVersion() + ")");
popup.setScene(new Scene(loader.getRoot()));
popup.initModality(Modality.NONE);
popup.initOwner(applicationWindow);
runnerActivityController.setAuthHandler(handler);
runnerActivityController.setPackage(pkg, packageList);
popup.showAndWait();
} catch (IOException ex) {
Logger.getLogger(EpicApp.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例3: clickItem
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
@FXML
public void clickItem(MouseEvent event) throws IOException
{
if (event.getClickCount() == 2) {
stage = (Stage) label.getScene().getWindow();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/callib/Views/BorrowedDetails.fxml"));
Stage modal = new Stage();
modal.initModality(Modality.APPLICATION_MODAL);
modal.setScene(
new Scene((Pane) loader.load())
);
modal.setX(stage.getX() + 50);
modal.setY(stage.getY() + 50);
BorrowedDetailsController controller = (BorrowedDetailsController) loader.getController();
controller.initData(table.getSelectionModel().getSelectedItem().getId());
modal.showAndWait();
this.displayData();
}
}
示例4: showRulesScreen
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public void showRulesScreen(){
try {
// Load person overview.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("/main/java/view/RulesScreen.fxml"));
AnchorPane mainAnchor = (AnchorPane) loader.load();
RulesScreenController controller = loader.getController();
controller.setMainApp(this);
controller.handleGoalGame();
primaryStage.getScene().setRoot(mainAnchor);
if(OptionManager.isFullscreen())
primaryStage.setFullScreen(true);
else
primaryStage.setFullScreen(false);
// Set person overview into the center of root layout.
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: ProjectPanePresentation
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public ProjectPanePresentation() {
final URL location = this.getClass().getResource("ProjectPanePresentation.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(location);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
try {
fxmlLoader.setRoot(this);
fxmlLoader.load(location.openStream());
controller = fxmlLoader.getController();
initializeRightBorder();
initializeBackground();
initializeToolbar();
initializeToolbarButton(controller.createComponent);
} catch (final IOException ioe) {
throw new IllegalStateException(ioe);
}
}
示例6: loadFXML
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
/**
* Loads the given FXML and instantiates the controller associated with it.
* Typically you should use {@link BaseController#loadFXML(Class, String)} instead.
* @param fxmlLocation The location of the FXML file to load.
* @param clazz The class of the controller to instantiate.
* @return The controller for the given FXML file.
*/
public static <T extends BaseController> T loadFXML(String fxmlLocation, Class<T> clazz) {
FXMLLoader fxmlLoader = new FXMLLoader(clazz.getResource(fxmlLocation));
try {
Parent root = (Parent) fxmlLoader.load();
T controller = fxmlLoader.getController();
controller.fxmlRoot = root;
controller.currentScene = new Scene(root);
controller.currentScene.getStylesheets().add(GUILauncher.class.getResource("css/style.css").toString());
return controller;
}
catch (Exception exception) {
displayErrorPopup(exception, "Fatal Error Encountered: ");
throw new RuntimeException(exception);
}
}
示例7: start
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception{
// Create a new database file if one does not currently exist
DatabaseHelper.createDatabase();
// Creates the main view of the application
FXMLLoader root = new FXMLLoader(getClass().getResource("/view/mainTabPane.fxml"));
primaryStage.setTitle("Recordian");
primaryStage.setScene(new Scene(root.load()));
primaryStage.setOnCloseRequest(event -> Platform.exit());
MainTabPaneController mainTabPaneController = root.getController();
mainTabPaneController.setCurrentStage(primaryStage);
primaryStage.show();
}
示例8: setupLogController
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public static void setupLogController() {
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL fxmlUrl = classLoader.getResource("gui/log.fxml");
if (fxmlUrl == null) {
OneClientLogging.logger.error("An error has occurred loading instance_creation.fxml!");
return;
}
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(fxmlUrl);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
Parent root = fxmlLoader.load(fxmlUrl.openStream());
stage = new Stage();
stage.setTitle("One Client - Log");
stage.getIcons().add(new Image("images/icon.png"));
stage.setResizable(true);
stage.setAlwaysOnTop(false);
stage.initOwner(Main.stage);
stage.initModality(Modality.NONE);
Scene scene = new Scene(root, 600, 300);
scene.getStylesheets().add("gui/css/theme.css");
stage.setScene(scene);
logController = fxmlLoader.getController();
logController.setStage(stage);
TextAreaAppender.setTextArea(logController.logArea);
} catch (Exception e) {
OneClientLogging.error(e);
}
}
示例9: start
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("sample.fxml"));
Parent root = fxmlLoader.load();
Screen screen = Screen.getPrimary ();
// 界麵初始化
Controller controller = fxmlLoader.getController();
controller.init(primaryStage);
Rectangle2D bounds = screen.getVisualBounds ();
double minX = bounds.getMinX ();
double minY = bounds.getMinY ();
double maxX = bounds.getMaxX ();
double maxY = bounds.getMaxY ();
screenWidth = maxX - minX;
screenHeight = maxY - minY;
Scene scene = new Scene(root, (maxX - minX) * 0.6, (maxY - minY) * 0.6);
primaryStage.setTitle ("Higher Cloud Compute Platform");
primaryStage.setScene (scene);
primaryStage.setFullScreen(true);
primaryStage.show ();
}
示例10: TrackerPaintStage
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
private TrackerPaintStage() {
FXMLLoader loader = new FXMLLoader(
getClass().getClassLoader().getResource(
"FXML/TrackerPaintScene.fxml"));
try {
root = loader.load();
paintStageController = loader.getController();
} catch (Exception e) {
e.printStackTrace();
}
this.setTitle("Visualisation options");
if (root != null) {
Scene scene = new Scene(root, 1000, 500);
this.setScene(scene);
}
}
示例11: openPatientEditStage
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
private void openPatientEditStage(int patientId) {
FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("/view/patient/EditPatient.fxml"));
try {
Parent root = fXMLLoader.load();
EditPatientController controller = fXMLLoader.getController();
controller.getPatientDetails(patientId);
Stage stage = new Stage();
stage.initModality(Modality.WINDOW_MODAL);
stage.setTitle("Edit Patient");
stage.setScene(new Scene(root));
stage.show();
} catch (IOException ex) {
Logger.getLogger(PatientsController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例12: newInstance
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public static AssocSelectionDialogController newInstance(UIToolBox toolBox) {
final ResourceBundle bundle = toolBox.getI18nBundle();
FXMLLoader loader = new FXMLLoader(AssocSelectionDialogController.class
.getResource("/fxml/AssociationSelectionPane.fxml"), bundle);
try {
loader.load();
return loader.getController();
}
catch (Exception e) {
throw new RuntimeException("Failed to load AssocSelectionPane from FXML", e);
}
}
示例13: Page
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public Page(String title, PagePane pagePane) {
this.setText(title);
setClosable(true);
tooltip=new Tooltip();
tooltip.setText(title);
tooltip.textProperty().bind(this.textProperty());
try {
StackPane headerArea = (StackPane) pagePane.lookup(".tab-header-area");
URL location = getClass().getResource("/fxml/tab_content.fxml");
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(location);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
Parent parent = fxmlLoader.load(location.openStream());
// FXMLLoader fxmlLoader=new FXMLLoader(Res.getFxmlRes("tab_content"));
// Pane parent=fxmlLoader.load();
setContent(parent);
controller=fxmlLoader.getController();
controller.getHeader().prefWidthProperty().bind(pagePane.widthProperty());
controller.getContainer().prefWidthProperty().bind(pagePane.widthProperty());
controller.getContainer().prefHeightProperty().bind(pagePane.heightProperty()
.subtract(headerArea.heightProperty())
.subtract(controller.getHeader().heightProperty()));
this.setOnClosed(controller::close);
controller.setTab(this);
controller.setPagePane(pagePane);
} catch (IOException e) {
e.printStackTrace();
}
}
示例14: editorButtonAction
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
/**
* Method to be called on editor button click
* @param event click event
*/
public void editorButtonAction(ActionEvent event) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/Editor.fxml"));
Parent root = loader.load();
editorController = (EditorController) loader.getController();
fileChooser.setTitle("Select song");
fileChooser.getExtensionFilters().clear();
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("MP3", "*.mp3"));
File songFile = fileChooser.showOpenDialog(stage);
if (songFile == null) {
return;
}
Stage editorStage = new Stage();
editorStage.setTitle("Clone Hero Editor");
editorStage.setScene(new Scene(root));
editorStage.setResizable(false);
editorStage.getIcons().add(new Image(getClass().getResource("/icon.png").toString()));
editorStage.show();
editorController.setSongPath(songFile.toURI().toString());
editorController.start();
//((Node)(event.getSource())).getScene().getWindow().hide();
} catch (IOException e) {
e.printStackTrace();
}
}
示例15: showEditQuestionDialog
import javafx.fxml.FXMLLoader; //導入方法依賴的package包/類
public static boolean showEditQuestionDialog(Stage ps,Question question,String title){
try {
// Load the fxml file and create a new stage for the popup dialog.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view_controller/EditQuestion.fxml"));
GridPane page = loader.load();
// Create the dialog Stage.
Stage dialogStage = new Stage();
dialogStage.setTitle(title);
dialogStage.getIcons().add(new Image(MainApp.class.getResourceAsStream("resources/icon.png")));
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(ps);
Scene scene = new Scene(page);
dialogStage.setScene(scene);
dialogStage.setWidth(450);
dialogStage.setHeight(700);
dialogStage.setResizable(false);
// Set the question into the controller.
EditQuestionCtrl controller = loader.getController();
controller.dialogStage = dialogStage;
controller.setQuestion(question);
// Show the dialog and wait until the user closes it
dialogStage.showAndWait();
return controller.okClicked;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}