I'm just starting with SceneBuilder and JavaFX. I've opened a test project and am checking out SceneBuilder. Added Label to the AnchorPane and wanted to change the font of the text. But I don't see any fonts installed in my system by me. I've already had some fonts installed in Windows before (Next Art, Montserrat, Bebas Neue). Neither of them is shown in SceneBuilder. I didn't find any helpful information on this problem. I've seen youtube videos where people choose their custom fonts directly from SceneBuilder. Am I doing something wrong?
P.S.: I know that I could simply write some code and integrate any font using CSS for example. But yet want to do it in SceneBuilder.
(I use Java SDK v.14.0.2, JavaFX v.11.0.2 and SceneBuilder v.11.0.0)
Finally, I managed to make it work properly. Yet the answer was in an unanswered question here on the site :D.
Well, the reason why SceneBuilder doesn't see my custom fonts is that they weren't installed for all users.
Windows 10 stores your custom fonts in this folder:
C:\Users\<username>\AppData\Local\Microsoft\Windows\Fonts
But the system does it if you simply open the font and click "Install" button or drag-and-drop it to Start>Settings>Personalization>Fonts or C:\Windows\Fonts folder.
To make your fonts visible in SceneBuilder on Windows 10
If you already had them installed in your system:
backup your font/fonts from C:\Windows\Fonts folder
delete it/them from there (otherwise fonts will be doubled later)
Select your custom font/fonts
Right-click it/them and choose Install for all users option (but not Install)
Relaunch your IDE and SceneBuilder.
Now you should be able to choose your custom fonts directly from SceneBuilder.
That helped me, thanks to the user d3f4lt.
Related
I am running Windows 10 64 bit and have JDKs and JRE 8 (1.8.0_152) and 9(9.0.1) installed.
I have a GUI (Swing) that I am working on in IntelliJ IDEA Community 2017.2. I have setup Icon and Font sizes to my liking and the program runs and looks when it is run inside IntelliJ. I have created an Artifact (JAR) and everything shows correctly IF it is run inside IntelliJ. However, IF I run (double-click) the JAR file outside IntelliJ, all icons and text are bigger/scaled up and they look blurry. I have IntelliJ run all projects with 1.8.
I have read about Java/Swing DPI scaling (apparently Swing reports that it can do scaling or something like that and in turn Windows tries to scale up the program) but I do not fully understand what that is and what is going on.
I have also looked at using launch4j because if the JAR is wrapped it might not suffer from DPI scaling, is this correct?
What can I do to run my JAR file and that it looks exactly as it looks inside IntelliJ?
Thank you very much!
P.S.: This is the program when run inside IntelliJ
This is the program when running (double clicking) the JAR
I have solved the problem!
I found this post here:
How to set the DPI of Java Swing apps on Windows/Linux?
Even though, the OP had a different problem (the fonts on his Java Swing app are too small and the app DOES NOT scale up automatically) the following two answers helped me find the solution:
The first answer shows some research on the Swing LAF (Look And Feel) and that only JavaFX supports DPI scaling to 150% on this person's system.
The second answer tells to run the app using JRE 9!!! and explains that it supports DPI scaling for Swing and AWT.
So... I set up IntelliJ to use JDK 9 and... Ugly icons and scaled-up text showed up in the app running inside IntelliJ!!!
Then it hit me!
I have both JRE 8 AND JRE 9 (and also JDK 1.8 & JDK 9) installed in my system... Of course my system is using the latest one!!! (I was just to blind to see that, actually it never crossed my mind to think about this)
Basically, I was developing in IntelliJ using JDK 1.8 and then running the JAR file using the default JRE on my system (JRE 9 which has DPI scaling capabilities for Swing applications).
I ran my JAR file explicitly using JRE 1.8 like this:
c:\path-to-jar>"path-to-my-jre1.8.0_151-javaw.exe" -jar MyJAR.jar
And... icons and text showed up correctly!
Hope this helps someone!
I'm trying to get started with JavaFX, using Eclipse with Java 8. However, I'm unable to install e(fx)clipse, and I won't be able to.
For now I'm trying to use the scene builder on it's own. I have created a layout and I can create an FXML file, but Eclipse doesn't seem to know what to do with it. Is there a way to get the Java source code out of the Scene Builder? Or maybe some configuration to Eclipse to make it know what to do with FXML?
FXML are just XML files which are loaded and converted into views. These can be loaded in your application irrespective of whether you have a plugin installed or not. For more information on how to use FXML in your application, go through
Introduction to FXML
Which is better way of programming in javafx?
You may or may not use FXMLs at all. FXML is just a support added to JavaFX to separate the view from the logic. If you want to you can use plain Java to create views for you application.
Moreover, you can link fxml files in eclipse to open with scene builder by default.
Right click on any FXML file -> Open With -> Other -> External Program -> Browse for Scene Builder application -> Check the box with text "Use it for all *.fxml files"
As of now, there isn't any support to get Java source out of FXML. For more information go through
How to Convert FXML to JAVA
Can JavaFX scenebuilder used to create Java Code instead of FXML
I recommend you to use JavaFX Scene Builder 2.0
It's great standalone tool where you even can create events for components and copy paste to your code.
I use this tool in conjunction with the latest version on Netbeans but you can use it with eclipse too.
This tool can be downloaded from the Oracle website .
I've been figuring out how to integrate Gluon Scene Builder into my IDE of choice and decided it would be a good share with the Stack Overflow community for those of you who have had trouble with this in the past. Keep in mind this is for those who have had prior experience with JavaFX and Gluon Scene Builder, minimal at least.
I haven't "scene" any posts directly addressing integration of SceneBuilder as a tutorial so I figured I would set it nice and simple since there were a few questions roaming around.
THIS GUIDE IS FOR ECLIPSE
AND USES GLUON'S SCENEBUILDER
Note this guide is intended for those lightly to moderately experienced with JavaFX as an application builder
//INTELLIJ AND NETBEANS WILL COME LATER PER DEMAND FOR EACH
Alright guys, here we go.
Step 1) Open up your Eclipse IDE(preferably with JavaFX installed prior to installing SceneBuilder) and a web browser of your choice.
You will need elements of JavaFX in order to properly implement SceneBuilder.
Step 2) Click or browse with this link: http://gluonhq.com/open-source/scene-builder/
Select your current operating system on which you will be installing SceneBuilder.
SceneBuilder's default location on Windows is in C:\Users\YourUserFolder\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Gluon, but of course it is more than possible and recommended to change the path while downloading.
Step 3) Once SceneBuilder is downloaded and installed, close SceneBuilder and find the .exe file on your PC(or Mac) where you chose to install it to or in it's default location.
Copy SceneBuilder.exe's file path. For example if you allowed SceneBuilder to install in it's default location, the file path would be: C:\Users\YourUserFolder\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Gluon\SceneBuilder.exe
Now we need to associate FXML files with SceneBuilder
Step 4) Associate FXML with SceneBuilder.
Still inside Eclipse, click Windows at the top > Preferences > search "File Associations"
Browse for the SceneBuilder.exe file path we copied earlier and click OK.
Step 5) Return to the Eclipse IDE and open up a JavaFX Project and name it "test".
File > New > Other > JavaFX Project OR (Ctrl + N) > JavaFX Project
Go into the src folder of test project.
Create an FXML file: test > src > application > New > Other > New FXML Document
Name your FXML file "testfx"
Congratulations, upon firing up your FXML document, you should be billed with a SceneBuilder window. If not you may not have associated FXML documents correctly.
Now how to implement the code is for a different time. For now this tutorial is all I've got within me! If you guys found this helpful, shoot me a pm and let me know! I appreciate your feedback and would like to be able to build upon this greatly.
Thanks guys,
Happy Programming!
Eclipse integration with Gluon Executable JAR on Windows
Parameters/Preconditions used in this example:
Folder for SceneBuilder: c:\example\
Version: scenebuilder-all-8.3.0-all.jar
Eclipse Version: Neon.3 Release (4.6.3)
Install e(fx)clipse Plugin: http://www.eclipse.org/efxclipse/install.html
e(fx)clipse Version used: 2.4.0
Step by Step
Download "Executable JAR" from Gluon to folder c:\example\.
http://gluonhq.com/products/scene-builder/#download
Create Batch File "c:\example\scene_builder.bat" and add the following line:
"java.exe" -jar "%~dp0\scenebuilder-all-8.3.0-all.jar" %*
Double click batch file to test it, SceneBuilder should start
In Eclipse open Window - Preferences - JavaFX
SceneBuilder executable: c:\example\scene_builder.bat
Right click on fmxl File in Eclipse and click Open in ScenenBuilder
Comments
"java.exe"
If Java is not installed in the default way, specify the whole path to executable in quotation mark. "C:\Program Files\Java\jre1.8.0_131\bin\java.exe"
%~dp0\
Will open SceneBuilder JAR in the directory of the batch file
%*
Will pass all command line arguments passed to the batch file to SceneBuilder call
You have to download scenebuilder. Once downloaded you need to move it as it is downloaded in a strange place.
You then need to add an external jar as a library.
If you have already got fx support in eclipse set up. Create a new java fx project. Then create a new fxml file. You should now be able to open the fxml file with scene builder by right clicking on it.
I cannot do it better than this guy on the video tutorial. You obvisouly need java fx support first which is covered in tutorial 2-3.
http://m.youtube.com/watch?v=2j-e1CHsqsE
I use IntelliJ IDEA IDEA to do some JAVA GUI application. It embeds the scene builder. However, you have to install scene builder as well.
Here is the screen of it:
1. build a javafx application first
2. find your-application.fxml, then go to bottom left, there is a button Scene builder. (if you haven't install scene builder, it will ask you the path of your scene builder)
Scene Builder
I have a little problem when i'm installing eclipse on my elementaryOS. In fact, this problem persists when i'm using ubuntu gnome or unity.
I have eclipse on my home folder, and I create a eclipse.desktop. The icon looks good, but when I open eclipse, another blurry icon appears (Its name is "Java - Eclipse") apart of the normal icon.
I want have only the normal icon. I read about some similar troubles with the google chrome icon but the threads can't help me.
Can anyone helps me?
Thanks in advance.
My desktop entry is on /usr/share/applications/eclipse.desktop
That's normal behavior for eclipse.exe. The icon you have on your desktop is the eclipse launcher, which is not the same as the actual eclipse IDE.
You can read more about how and why here.
I have downloaded the entire pack from http://developer.android.com/design/downloads/index.html
I want to know how to use those. Do I place it somewhere in the android sdk folder so that it is visible in my Graphical Layout in Eclipse editor or should i be using the individual icons and fonts as required in my project by placing it in the drawable-hdpi folder?
Thanks in advance.
If you are using one of the latest versions of the Android Development Tools in Eclipse, you can just go to New->Other, and the Android->Android Icon Set and it will show you a step by step Wizard where you can select all those images, the color, name, sizes, and it will automatically place the different versions in the corresponding folders.
You can check it out here. Also, at the beggining of the linked page, thereĀ“s another link to the web app version that allows you to easily create nine-patch images, besides icons and other assets.
You have to put them manually in the drawable-mdpi/hdpi/xhdpi folders.