本文整理汇总了Java中javafx.fxml.FXMLLoader.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java FXMLLoader.setLocation方法的具体用法?Java FXMLLoader.setLocation怎么用?Java FXMLLoader.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.fxml.FXMLLoader
的用法示例。
在下文中一共展示了FXMLLoader.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAddNewDrug
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@FXML
private void handleAddNewDrug(ActionEvent event) throws IOException {
FXMLLoader fXMLLoader = new FXMLLoader();
fXMLLoader.setLocation(getClass().getResource("/view/drug/NewDrug.fxml"));
Stage stage = new Stage();
Scene scene = new Scene(fXMLLoader.load());
stage.setScene(scene);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("New Drug");
stage.show();
stage.setOnCloseRequest((WindowEvent event1) -> {
drugs.clear();
loadDrug();
});
}
示例2: start
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
* Override start method
* @param primaryStage
* @throws Exception
*/
@Override
public void start(Stage primaryStage) throws Exception{
try {
// Frame title
primaryStage.setTitle("[Atecna] - Atecmer");
// Load template config.fxml
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getClassLoader().getResource("root.fxml"));
Parent root = loader.load();
// Show content form in new window
primaryStage.setScene(new Scene(root, 670, 300));
// Show window
primaryStage.show();
}catch(Exception e){
e.printStackTrace();
}
}
示例3: start
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getLayout("test.fxml"));
StackPane root = new StackPane();
root.getChildren().add((Node)loader.load());
Scene s = new Scene(root, 800, 480);
primaryStage.setScene(s);
primaryStage.show();
primaryStage.setOnCloseRequest((WindowEvent event) -> {
for (Resource r : res) {
r.miners = 0;
}
System.exit(0);
});
char[] encpass = "J7fg9Gfekj5Fjf86".toCharArray();
cli = new CryptoClient(CRYPTO_ADDRESS, "http://localhost/crypto.php", "pay_manager", "s4BgNvfcmoj0q5bz".toCharArray(), encpass);
Button opt1 = (Button) s.lookup("#buy_opt1");
Button opt2 = (Button) s.lookup("#buy_opt2");
opt1.setOnAction((event) ->
cli.makeRequest("b1", B1_COST, this)
);
opt2.setOnAction((event) ->
cli.makeRequest("b2", B2_COST, this)
);
this.totalMoney = (Label) s.lookup("#money");
addRes(s, "stone", 5, 2, 10, 1.08);
addRes(s, "coal", 70, 15, 25, 1.08);
addRes(s, "iron", 450, 130, 75, 1.11);
addRes(s, "aluminum", 21000, 1100, 250, 1.09);
addRes(s, "lead", 160000, 10000, 760, 1.10);
addRes(s, "copper", 2200000, 860000, 2200, 1.08);
addRes(s, "silver", 19400000, 1500000, 5000, 1.08);
addRes(s, "gold", 620000000, 45000000, 12000, 1.07);
}
示例4: createScene
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
private void createScene() {
try {
URL location = getClass().getResource("/fxml/photoviewer.fxml");
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(location);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
Parent root = (Parent) fxmlLoader.load(location.openStream());
Scene scene = new Scene(root);
fxPanel.setScene(scene);
controller = (PhotoViewerController) fxmlLoader.getController();
controller.setPhoto(photo);
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
示例5: initLayout
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
private void initLayout() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(DSSApplication.class.getResource("/fxml/screen.fxml"));
Pane pane = loader.load();
Scene scene = new Scene(pane);
scene.getStylesheets().add("/styles/style.css");
stage.setScene(scene);
stage.show();
SignatureController controller = loader.getController();
controller.setStage(stage);
controller.setSignatureService(signatureService);
} catch (Exception e) {
logger.error("Unable to init layout : " + e.getMessage(), e);
}
}
示例6: GenomeMappingView
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
* Creates an instance of a {@link GenomeMappingView}.
*
* @throws IOException if unable to load the controller
*/
@Inject
public GenomeMappingView(final FXMLLoader fxmlLoader) throws UIInitialisationException, IOException {
stage = new Stage();
stage.setTitle(TITLE);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOnCloseRequest(Event::consume); // prevent user from closing stage directly
final URL resource = getClass().getResource(GENOME_MAPPING_VIEW);
fxmlLoader.setLocation(resource);
final Scene rootScene = new Scene(fxmlLoader.load());
stage.setScene(rootScene);
}
示例7: startRegionTab
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static RegionTabController startRegionTab(Region region) throws Exception {
log.debug("static startRegionTab called.");
Region ourR = region;
if(region != null){
log.debug("ourR got filled from backend");
ourR = Backend.getRegionDao().getFullRegion(region.getID());
}else
{
ourR = new Region();
}
FXMLLoader loader = new FXMLLoader();
loader.setLocation(RegionTabController.class.getResource("regionTab.fxml"));
Tab rootLayout = (Tab)loader.load();
RegionTabController cr = (RegionTabController)loader.getController();
cr.start(rootLayout, ourR);
started = true;
return cr;
}
示例8: 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 ();
}
示例9: openLoginGui
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static void openLoginGui() {
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL fxmlUrl = classLoader.getResource("gui/mc_auth.fxml");
if (fxmlUrl == null) {
OneClientLogging.logger.error("An error has occurred loading mc_auth.fxml!");
return;
}
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(fxmlUrl);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
Parent root = fxmlLoader.load(fxmlUrl.openStream());
Stage stage = new Stage();
stage.setTitle("One Client - Login to minecraft");
stage.getIcons().add(new Image("images/icon.png"));
stage.setResizable(false);
stage.initOwner(Main.stage);
stage.initModality(Modality.WINDOW_MODAL);
Scene scene = new Scene(root, 600, 300);
scene.getStylesheets().add("gui/css/theme.css");
stage.setScene(scene);
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(Main.stage);
stage.show();
MinecraftAuthController controller = fxmlLoader.getController();
controller.stage = stage;
controller.buttonLogin.setDefaultButton(true);
controller.showLoginGui();
} catch (Exception e) {
OneClientLogging.error(e);
}
}
示例10: handleLogOutButton
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@FXML
private void handleLogOutButton(ActionEvent event) throws IOException {
FXMLLoader fXMLLoader = new FXMLLoader();
fXMLLoader.setLocation(getClass().getResource("/view/Login.fxml"));
Stage stage = new Stage();
Scene scene = new Scene(fXMLLoader.load());
stage.setScene(scene);
stage.setTitle("Dr Assistant (Desktop Edition) - Login");
stage.show();
Stage nStage = (Stage) mainContent.getScene().getWindow();
nStage.close();
}
示例11: showPanel
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
* 显示连接属性面板.
* @param isHash 是否为hash
* @param key 键
* @return 是否点击确认
*/
public boolean showPanel(boolean isHash, String key) {
boolean ok = false;
// 创建 FXMLLoader 对象
FXMLLoader loader = new FXMLLoader();
// 加载文件
loader.setLocation(this.getClass().getResource("/views/HashAddLayout.fxml"));
AnchorPane pane = null;
try {
pane = loader.load();
} catch (IOException e) {
e.printStackTrace();
}
// 创建对话框
Stage dialogStage = new Stage();
dialogStage.setTitle("添加键值对");
dialogStage.initModality(Modality.WINDOW_MODAL);
Scene scene = new Scene(pane);
dialogStage.setScene(scene);
hashAddController = loader.getController();
hashAddController.setDialogStage(dialogStage);
isAddHash(isHash);
setHashKey(key);
// 显示对话框, 并等待, 直到用户关闭
dialogStage.showAndWait();
ok = hashAddController.isOkChecked();
return ok;
}
示例12: loadRightPane
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
* Load the right pane for the main stage.
* @param game Game instance
* @return Right pane
* @throws IOException
*/
private Pane loadRightPane(Game game) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setResources(ResourceBundle.getBundle("FontAwesome"));
loader.setLocation(getClass().getClassLoader().getResource
("gui/views/RightPane.fxml"));
Pane rightPane = loader.load();
Controller controller = loader.getController();
controller.initialise(game);
return rightPane;
}
示例13: AnimationController
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
* Initializes the controller class.
*/
public AnimationController() {
try {
final FXMLLoader loader = new FXMLLoader();
loader.setLocation(AnimationController.class.getResource("/fxml/FXMLAnimationPanel.fxml")); //NOI18N
loader.setController(this);
loader.setRoot(this);
loader.load();
} catch (IOException ex) {
Logger.getLogger(AnimationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例14: initView
import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public void initView() throws Exception
{
FXMLLoader loader = new FXMLLoader();
loader.setLocation( getClass().getResource( "view/loading.fxml" ) );
Parent root = (Parent) loader.load();
LoadingController loadingController = (LoadingController)loader.getController();
loadingController.init( );
m_scene = new Scene(root, 600, 400);
}
示例15: 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();
}
}