Unable to load FXML when placed in a package - javafx-8

I got this type of file hierarchy in JavaFXApplication5 project.
Ive made another package for all the fxml files, so when project gets big it will be easier to find certain files.
Now in JavaFXApplication5 main class I have a line which Im sure causes an exception(java.lang.reflect.InvocationTargetException) when application is trying to run.
AnchorPane root = (AnchorPane) FXMLLoader.load(getClass().getResource("FXMLNew.fxml"));
Im sure its because the "FXMLNew.fxml" root is wrong. But I dont know how to set it when is in another package...?
Or maybe these type of files should be put in normal folder?

To load a fxml which is inside a package, use /package-name/fxml-file-name.fxml
For your case:
AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("/windows/FXMLNew.fxml"));

Related

UI Toolkit Custom Inspector Disappeared in Playmode Unity

I have created a custom inspector using the UI Toolkit. The way I initialize the UI Document is as follows:
public VisualTreeAsset uXML;
This uXML is assigned through the inspector. Then in CreateInspectorGUI:
root = new VisualElement();
if (uXML == null)
{
Debug.Log("UI Document is " + documentName + " null");
return root;
}
uXML.CloneTree(root);
The root is the main root of the UI document (I am using UI Toolkit).
The problem is that when I enter play mode, the Inspectors disappears as shown:
I’m going to assume that you used a “Default Reference” for your editor script. Unfortunately, the default reference is only deserialised when you're in "Edit" mode. As soon as you go to "Play" mode, the reference is null.
The general way to get around the issue is to search for your asset when you create the inspector window:AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/PathToYourFiles/YourFile.uxml")
Unfortunately, if you move your files somewhere else, you need to go in an update the string file location. Because it's a string path, there's no reference to follow the file if you move or rename the file. It's not clean, but it's easy, and gives you your inspector when in Play mode.
I did a quick search on the issue. Looking at this document, it seems Unity also suggest using Addressables or the Resources folder.
Because you don't really want the assets to follow you into a final build, I prefer placing them into an Editor folder, and just making sure I'm careful when moving or renaming the files. In one project, I made an automated process that "found" the file for me. It involved using a ScriptableObject and Assembly Reloads but I'm still in two minds whether the effort was worth it.

How to properly implement Find in Files in Custom Project?

I tried implement interface IVsProjectTextImageProvider. Method OpenItemTextImage is called for each file in project (files are packed inside project files - something like zip) but in there is still no result in Find Results window.
What i am missing?
It seams that item must be registered in Running Document Table.

Creating a Theme / Template for iOS application?

I am creating an application where there are some views i want to be available in each and every UIView Controller just like a master page in Web Development. i have created those views but how to add them to all the view controllers in the application automatically?
You should add them to mainWindow if you need to display them in all viewcontrollers.
Hope it helps you.
You need to convert the project and all the views that you created to a template first and then create a new project and use that template. Here is a guide I have used:
This guide explains how to create new project templates in Xcode. Project templates appear in the list of project types in the New Project dialog.
1.Create a new project and setup everything as you'd like (NIB files, graphics, sounds, settings, code etc)
Optionally, build and make sure the project works
Use Finder and locate the project folder for your project you created in step 1
Open another Finder window and navigate to /Library/Application Support/Apple/Developer Tools/Project Templates/. You have two options here:
Create a new folder for your custom project templates - this will appear as a category when creating a new project in XCode
Choose an already existing folder (eg Application) - this will place the project template in that category
5.Open the new/chosen category folder and create a new folder inside. You can name this new folder whatever you like and it will appear as the project template name.
6.Copy all files from the project folder in step 3 to the new template folder created in step 5.
7.Try to create a new project in Xcode. You should see your project template in one of the original categories or in the category you created, whichever you decided.
Note: If you built the project, delete the build folder from the template folder.
Hope this would help you out.
Create a base view controller class which will have all these UIViews added in its view. Additionally, you can also implement the events of these particular views in the controller. Other controllers that you create need to extend from this base view controller class.

JavaFX Scenebuilder does not see ids when FXML is in a different package than controller

i installed netbeans with java se7, and javafx samples are running fine. In scenebuilder, i can select an ID for each control defined and annotated with #FXML in my controller. however, i like my project organised. when i create a new package, and move my FXML file there, (myapp/views) and the controller stays in the root where it was -> myapp, then in scenebuilder does not seem to find the id.
I know about the 'controller class' in the FXML, but since i didn't move my controller, that should not be changed.
More specific, when both my controller and fxml are in the package 'holidayapp', it works. moving the fxml to a subpackage holidayapp/views', doesn't work. The controller class remains
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="holidayapp.HolidayViewController">
as the HolidayViewController remains in the root package. I do nothing else but moving the fxml file from the main package into a subpackage.
I would like to see the id's from the holidayViewController in my scenebuilder. Compoling and running with the fxml in a subpackage, was never any problem.
Thanks
I think you might be suffering from the following issue:
https://bugs.openjdk.java.net/browse/JDK-8091793
If you think you do, please consider to vote for and/or comment on this issue.
The way I worked with this was placing my Main class into the view (the one that extends Application). This gave me access to my Controller classes, their variables, and methods. This works for SceneBuilder 1.1.
I can only speak for when using Eclipse and not NetBeans so doing this may still result in nothing.

Griffon View Script Generated from NetBeans Not Showing

I developed a UI in NetBeans that I want to use in my Griffon application. I chose to do so because I don't have enough time to figure out how to get the screen laid out correctly using SwingBuilder. According to the book Griffon in Action, I basically just need to place the .java file created in NetBeans under the appropriate package in the src directory of my Griffon project and run the griffon generate-view-script command with the fully qualified class name of the .java class (it took me a while to figure out how to do that). It then generates a .groovy file in the views directory that contains some code wrapping the .java class to make it work with SwingBuilder. When I try to run this as-is, nothing comes up. There are no exceptions being thrown, but nothing shows up either.
As it turns out, the .java class contains a Main() method in which the visible property of the class (it is a subclass of JFrame) is set to true. The Main() method does not get called by SwingBuilder, so the visible property was never being set to true. To correct this, I just had to add visible: true to the parameters to the generated widget node like below.
widget(new package.path.MyClass(), id: 'MyClass', visible: true)
Once I did that, it came up just fine.