本文整理了Java中javafx.fxml.FXMLLoader.setController()
方法的一些代码示例,展示了FXMLLoader.setController()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FXMLLoader.setController()
方法的具体详情如下:
包路径:javafx.fxml.FXMLLoader
类名称:FXMLLoader
方法名:setController
暂无
代码示例来源:origin: pmd/pmd
public void showExportXPathToRuleWizard() {
ExportXPathWizardController wizard
= new ExportXPathWizardController(xpathExpressionProperty());
FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/xpath-export-wizard.fxml"));
loader.setController(wizard);
final Stage dialog = new Stage();
dialog.initOwner(designerRoot.getMainStage());
dialog.setOnCloseRequest(e -> wizard.shutdown());
dialog.initModality(Modality.WINDOW_MODAL);
Parent root;
try {
root = loader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
Scene scene = new Scene(root);
//stage.setTitle("PMD Rule Designer (v " + PMD.VERSION + ')');
dialog.setScene(scene);
dialog.show();
}
代码示例来源:origin: io.datafx/flow
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration)
throws FxmlLoadException {
Class<?> controllerClass = controller.getClass();
String foundFxmlName = getFxmlName(controllerClass);
if (fxmlName != null) {
foundFxmlName = fxmlName;
}
if (foundFxmlName == null) {
throw new FxmlLoadException("No FXML File specified!");
}
FXMLLoader fxmlLoader = new FXMLLoader(
controllerClass.getResource(foundFxmlName));
fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory());
fxmlLoader.setCharset(viewConfiguration.getCharset());
fxmlLoader.setResources(viewConfiguration.getResources());
fxmlLoader.setController(controller);
fxmlLoader.setControllerFactory(c -> controller);
return fxmlLoader;
}
代码示例来源:origin: pmd/pmd
private Stage createStage(Stage mainStage) {
FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("event-log.fxml"));
loader.setController(this);
final Stage dialog = new Stage();
dialog.initOwner(mainStage.getScene().getWindow());
dialog.initModality(Modality.NONE);
Parent root;
try {
root = loader.load();
} catch (IOException e) {
throw new IllegalStateException(e);
}
Scene scene = new Scene(root);
dialog.setScene(scene);
return dialog;
}
代码示例来源:origin: org.javafxdata/datafx-controller
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration)
throws FxmlLoadException {
Class<?> controllerClass = controller.getClass();
String foundFxmlName = getFxmlName(controllerClass);
if (fxmlName != null) {
foundFxmlName = fxmlName;
}
if (foundFxmlName == null) {
throw new FxmlLoadException("No FXML File specified!");
}
FXMLLoader fxmlLoader = new FXMLLoader(
controllerClass.getResource(foundFxmlName));
fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory());
fxmlLoader.setCharset(viewConfiguration.getCharset());
fxmlLoader.setResources(viewConfiguration.getResources());
fxmlLoader.setController(controller);
fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> arg0) {
return controller;
}
});
return fxmlLoader;
}
代码示例来源:origin: pmd/pmd
private Stage createEditPropertyDialog() {
EditPropertyDialogController wizard = new EditPropertyDialogController();
FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("edit-property-dialog.fxml"));
loader.setController(wizard);
final Stage dialog = new Stage();
dialog.initOwner(this.getScene().getWindow());
dialog.initModality(Modality.WINDOW_MODAL);
dialog.initStyle(StageStyle.UNDECORATED);
Parent root;
try {
root = loader.load();
} catch (IOException e) {
throw new IllegalStateException(e);
}
Scene scene = new Scene(root);
dialog.setTitle("Edit property");
dialog.setScene(scene);
dialog.setUserData(wizard);
return dialog;
}
代码示例来源:origin: jfoenixadmin/JFoenix
loader.setController(new InputController());
toolbarPopup = new JFXPopup(loader.load());
代码示例来源:origin: eu.agrosense.spi/session
public WorldPane() {
log.finest("constructing world pane");
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("WorldPane.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
代码示例来源:origin: eu.agrosense.spi/session
public FailurePane() {
getStyleClass().add("failure");
setMinWidth(220.0d);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FailurePane.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
代码示例来源:origin: eu.agrosense.spi/session
@Override
public void run() {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("Login.fxml"));
loader.setController(controller);
Parent root = (Parent) loader.load();
Scene scene = new Scene(root);
fxPanel.setScene(scene);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
});
代码示例来源:origin: dev.rico/rico-remoting-client-javafx
/**
* Constructor
* @param clientContext the client context
* @param controllerName the controller name of the controller definition on the server that should
* be used with this view.
* @param fxmlLocation the location (url) of the FXML file that defines the layout of the view.
*/
public AbstractFXMLViewController(ClientContext clientContext, String controllerName, URL fxmlLocation) {
super(clientContext, controllerName);
Assert.requireNonNull(fxmlLocation, "fxmlLocation");
try {
FXMLLoader loader = new FXMLLoader(fxmlLocation);
loader.setController(this);
rootNode = loader.load();
} catch (Exception e) {
throw new RuntimeException("Can not create view based on FXML location " + fxmlLocation, e);
}
}
代码示例来源:origin: com.github.giulianini.jestures/jestures
/**
* @param recognizer
* the {@link RecognitionScreenView}
*/
public RecognitionScreenView(final Recognition recognizer) {
super(recognizer);
this.recognizer = recognizer;
this.gestureLength = recognizer.getFrameLength();
// CREATE AND SET THE CONTROLLER. INIT THE BORDER PANE
Platform.runLater(() -> {
final FXMLLoader loader = new FXMLLoader();
loader.setController(this);
loader.setLocation(this.getClass().getResource(FXMLScreens.HOME.getPath()));
try {
this.recorderPane = (BorderPane) loader.load();
} catch (final IOException e1) {
e1.printStackTrace();
}
});
RecognitionScreenView.LOG.getClass();
}
代码示例来源:origin: org.drombler.fx/drombler-fx-core-commons
/**
* Loads the <class name>.fxml file, which is expected to be in the same package as the specified type.
* <br/> <br/>
* Sets:
* <ul>
* <li>the {@link ClassLoader} to the ClassLoader of the specified type</li>
* <li>the {@link ResourceBundle} by looking for a {@code Bundle.properties} file in the package of the specified
* type (or a locale specific derivation) using the default {@link Locale}</li>
* </ul>
*
* The root element of the FXML document is expected to be:
* <br/> <br/>
* {@code <fx:root type="{super-type}" xmlns:fx="http://javafx.com/fxml">}
* <br/> <br/>
* where "super-type" is the super type of the specified type.
* @param type the type
* @param rootController the Object acting as the root and as the controller.
* @throws IOException
*/
public static void loadRoot(Class<?> type, final Object rootController) throws IOException {
FXMLLoader loader = createFXMLLoader(type);
loader.setRoot(rootController);
loader.setController(rootController);
load(loader, type);
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
@Override
public Node createContent() {
FXMLLoader fxmlLoader=null;
if (controller.getFxmlResource() != GenericFilterController.EMPTY_DUMMY_URL) {
fxmlLoader = new FXMLLoader(controller.getFxmlResource());
fxmlLoader.setController(controller);
}
if (fxmlLoader != null) {
try {
return (Parent) fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
return new Group();
}
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
/**
* Load a content from an FXML definition
*/
protected Node loadFXML(URL fxmlLocation) {
try {
if (fxmlLocation != null) {
final FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(fxmlLocation);
fxmlLoader.setController(this);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
return fxmlLoader.load();
}
} catch (final IOException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
/**
* Load a content from an FXML definition
*/
public static Object loadFXML(URL fxmlLocation, Object controller) {
Object result = null;
try {
Assert.notNull(fxmlLocation);
Assert.notNull(controller);
final FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(fxmlLocation);
fxmlLoader.setController(controller);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
result = fxmlLoader.load();
} catch (final Exception e) {
e.printStackTrace();
throw new IllegalArgumentException(e);
}
return result;
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
public void openGuiColorsDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("GuiColors.fxml"));
GuiColorsController guiColorsController = new GuiColorsController(previewPane.getScene(), settingsModel);
loader.setController(guiColorsController);
try {
AnchorPane guiColorsPane = (AnchorPane)loader.load();
Scene scene = new Scene(guiColorsPane);
Stage dialog = new Stage();
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setScene(scene);
dialog.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: com.canoo.dolphin-platform/dolphin-platform-client-javafx
/**
* Constructor
* @param clientContext the DOlphin Platform client context
* @param controllerName the controller name of the Dolphin Platform controller definition on the server that should
* be used with this view.
* @param fxmlLocation the location (url) of the FXML file that defines the layout of the view.
*/
public AbstractFXMLViewBinder(ClientContext clientContext, String controllerName, URL fxmlLocation) {
super(clientContext, controllerName);
Assert.requireNonNull(fxmlLocation, "fxmlLocation");
try {
FXMLLoader loader = new FXMLLoader(fxmlLocation);
loader.setController(this);
rootNode = loader.load();
} catch (Exception e) {
throw new FxmlLoadException("Can not create view based on FXML location " + fxmlLocation, e);
}
}
代码示例来源:origin: us.ihmc/ihmc-robot-data-visualizer
@Override
public void start(Stage primaryStage) throws Exception
{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource(getClass().getSimpleName() + ".fxml"));
loader.setController(this);
loader.load();
controller.setMainWindow(primaryStage);
controller.enableNetworkProcessorClientProperty().set(true);
controller.setLidarScanMessageConsumer(lidarScanLogViewer::renderLidarScanMessage);
lidarScanLogViewer.start();
lidarScanLogWriterControlPaneController.initialize(controller, lidarScanLogViewer);
lidarScanLogReaderControlPaneController.initialize(controller);
View3DFactory view3dFactory = View3DFactory.createSubscene();
view3dFactory.addCameraController();
view3dFactory.addWorldCoordinateSystem(0.3);
view3dFactory.attachSubSceneTo(centerPane);
view3dFactory.addNodeToView(lidarScanLogViewer.getRoot());
primaryStage.setTitle(getClass().getSimpleName());
primaryStage.setScene(new Scene(mainPane, 600, 400));
primaryStage.show();
primaryStage.setOnCloseRequest(event -> stop());
}
代码示例来源:origin: us.ihmc/IHMCRobotDataVisualizer
@Override
public void start(Stage primaryStage) throws Exception
{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource(getClass().getSimpleName() + ".fxml"));
loader.setController(this);
loader.load();
controller.setMainWindow(primaryStage);
controller.enableNetworkProcessorClientProperty().set(true);
controller.setLidarScanMessageConsumer(lidarScanLogViewer::renderLidarScanMessage);
lidarScanLogViewer.start();
lidarScanLogWriterControlPaneController.initialize(controller, lidarScanLogViewer);
lidarScanLogReaderControlPaneController.initialize(controller);
View3DFactory view3dFactory = View3DFactory.createSubscene();
view3dFactory.addCameraController();
view3dFactory.addWorldCoordinateSystem(0.3);
view3dFactory.attachSubSceneTo(centerPane);
view3dFactory.addNodeToView(lidarScanLogViewer.getRoot());
primaryStage.setTitle(getClass().getSimpleName());
primaryStage.setScene(new Scene(mainPane, 600, 400));
primaryStage.show();
primaryStage.setOnCloseRequest(event -> stop());
}
代码示例来源:origin: us.ihmc/robot-environment-awareness
loader.setController(this);
loader.setLocation(getClass().getResource(getClass().getSimpleName() + ".fxml"));
mainPane = loader.load();
内容来源于网络,如有侵权,请联系作者删除!