How can I set an icon to the window of a JavaFX application? - netbeans

I made a JavaFX application on Netbeans and I put this code for setting the icon to the window
primaryStage.getIcons().add(new Image("file:sicadcam.png"));
and when I run the project from Netbeans, it works ok: the icon appears on the top left corner of the window and in the taskbar. The image is in the root directory of the project.
When I clean and build the project, it generates two installers: one exe and one msi; and when I install the application and open it, the window doesn't have the icon sicadcam.png, it has the default java logo icon.
How or where can I set the path of the image so that when I install the application the icon appears.

This is only a partial answer to the question as I have been unable to generate a self-contained package which shows the icon for the installed application in the Windows taskbar. I may have missed a step, have an environmental issue or the icon configuration for self-contained applications may be slightly buggy and may be fixed in later releases. Testing was on: jdk7u21, NetBeans 7.3, Win7, InnoSetup.
Get the icon image from a resource rather than a file.
For example, if you place the image in the source directory of your application class:
new Image(MyApplication.class.getResource("sicadcam.png").toExternalForm());
For an installed application, this will only set the icon displayed in the top left corner of the screen. To set the icon for the taskbar, desktop etc, following the instructions in the Self-Contained Packaging section of the JavaFX Deployment Guide is supposed to get you there.
For example to get an icon for the installer on my Windows 7 for my self-contained application, I needed to place the icon in a <netbeansprojectdir>/package/windows/<myappname>.ico (needs to be a .ico for the installer packager to pick it up) file AND ensure my ant path was configured correctly as detailed in How to change JavaFx native Bundle exe icon (hopefully that manual ant configuration won't be required in later NetBeans/JavaFX releases).
Download the Ensemble sample application from Oracle and see how the package directory is laid out there for platform specific icons. Unfortunately when I tried building Ensemble from the command line, I was also unable to get Windows 7 to use the Ensemble icon in the taskbar when Ensemble was installed and executed as a self-contained application.
Ensure your build system copies your icon into the jar file containing your application. To check this, change into the app directory of your installed application and run jar tvf <yourappjar>.jar => it should show the location of the icon resource file in the jar.

you can it by using getClass().getResourceAsStream("path.png")
the getResourceAsStream("path") is return an input stram for path of any file you are need it for example for icon
win.getIcons().add(new Image(getClass().getResourceAsStream("path.png")));
and if you are makking an jar file is run with out Exception

Related

How to create an applet for cinnamon Linux Mint 17.1 downloaded applications

Some applications like PostMan, SpringToolSuite etc. which has to be downloaded in tar.gz, .zip files from official websites would give a hard time in setting up applets for quick access on the Linux Mint panel.
So after cracking my head for 3 to 4 hours. I was able to create applet for faster access using this method.
I have found this problem for most of the applications that I downloaded from tar.gz and zip file Linux Mint doesn't automatically create an applet that can be used for quick access.
But on the contrary, deb files that are executable on double-click can automatically create applet for quick access as it compiles with help of package installer.
So the solution that I followed is:
Extract the compressed package which generates a folder.
Right click and choose the option Create a new launcher here...
Select the name and select the main executable provided in the
generated folder.
This would create a rocket icon launcher(as of Linux Mint 17.1)
Right Click that icon and open in text-editor add this line
Icon=/icon-location..
Click on Menu type the rocket icon launcher Name that you given in
step 3
Right click on the result that has rocket icon launcher, add to
panel
That's it!!

how to make sure that exported Eclipse RCP application works in MAC.

1) created simple hello world eclipse app.
2) product configuration created.
3)In overview tab of product Configuration clicked on "Eclipse Product Export Wizard"
4)Destination chosen as Archive file and stored in local system.
5)extracted the zip folder and if i click on icon it is successfully showing the exported result.
6)But if I copy the zip folder in mac and if i extract and try to click on the .exe it is not showing the proper result instead it was showing Archive window.
I would like to know what steps should follow so that exported Eclipse RCP application(which built on windows) works in mac.
quicker response would help me to fix my issue.thanks in advance.
RCP builds are specific to a single operating system (Mac, Linux, Windows), GUI system (Cocoa, GTK, Windows) and architecture (64 bit, 32 bit). You will have to build separate Mac and Windows builds.
To build for multiple platforms you have to set up a target platform which includes the Mac specific code (and any other platforms you want). Using a target platform based on one of the Eclipse software sites will give you this.
Once you have done this the Export wizard will let you export for multiple platforms and lets you choose which platforms to export for.
I have done below steps to solve this issue
1)window+preference+TargetPlatform+select running platform +click on Edit.
2)then popup will open + click on add +click on istallation/software site+provide delta pack path.
3)so that when ever we trying to export RCP product from "Export product configuration" in product file we can observer the multiple platforms oprion in that dialog box.

Javafx 8 NetBeans titlebar icon with native packaging

I need some help with NetBeans and a JavaFX project
When I try to install an icon in the title bar of a Windows 7
Desktop application it will not show up
Here are the steps I have used to create and EXE file
Main Class adds the icon with this line of code that works in Eclipse
pStage.getIcons().add(new Image(“file:src/Photos/C.ico”));
Inno Setup 5.0 installed and in Path
the icon is 32 by 32 and 32 bit depth it was created with GreenFish Icon maker
the icon is under Source Package in a folder named Photos
right click project select Properties select Deployment
check Enable Native Packaging
set the path to the icon for Native Package Icons
src/Photos/C.ico
Run Clean and Build
Run Package As EXE
The only other concern I have is this output message
No base JDK Package will use system JRE
I see this as a separate issue so as a bonus question
can I ask for help with how to include the JDK or JRE
so this application is independent of what JRE if any
is installed on the end user machine.
A side note during development if I use C.bmp
in place of the ico file the title bar will display
the bmp. The bmp file will not work at build time.
#James_Duh I have no idea why this works and I doubt you find this FIX anywhere else as I searched the net for why you need to use a bmp and ico file
Here is what I did with NetBeans 8.0.? and JDK1.8.0_51 on Windows 7
in the Main.class I used this line of code
Image ico = new Image("Photos/C.bmp"); NetBeans
Image ico = new Image("file:Photos/C.bmp"); Eclipse
Then in the Photos folder I placed an icon named C.ico 32 by 32
this icon is used to populate the installer EXE file
which when you run the EXE file the icon will be displayed
in the Start Menu
I also checked Desktop Icon and Start Menu shortcut under
Deployment in NetBeans Deployment screen
The Native Package deployment process in Eclipse is a real real PAIN
In the future I will make the switch to NetBeans IDE for this reason alone

LibGDX's HTML project doesn't show anything in Browser

The question is self explanatory, when I run my demo-html project as a Web Application and I open Chrome with the provided link by eclipse, my browser doesn't show the image it is supposed to show in a new project.. However, the tab displays the correct title "Demo". Can somebody help me with this?
Eclipse after Running the project:
And Chrome running the app:
You don't run it as web application. The simplest way is to run
gradle html:superDev
in command line. I'm not very familiar with Eclipse, so here a guide how to run it via IDE from the wiki:
Right click the html project, Run As -> External Tools Configuration. Create a new configuration by double clicking the Program entry in the left sidebar. Give the configuration a name, e.g. GWT SuperDev. Set the location field to the gradlew.bat (Windows) or gradlew (Linux, Mac) file. Set the working directory to the root folder of your project. Specify html:superDev as the Argument. Press 'Apply', then 'Run'. Wait until you see the message The code server is ready. in the console view, then open the URL http://localhost:8080/html. You can leave the server running. If you change code or assets, simply click the SuperDev Refresh button in the browser. This will recompile your app and reload the site.
In IntelliJ you can trivially run the gradle task itself.

Splash screen does not show up when product export

When i run my rcp application inside eclipse the splash screen is showing as it should. But when i export the product splash screen does not show up even if it is a new rcp application where i did not change splash screen at all
Did you add the splash screen image to the build.properties file?
if not, the image is not part of your generated *.jar file
Example:
bin.includes = splash.bmp,\
product.properties,\
about.ini,\
about.properties,\
plugin_customization.ini,\
META-INF/
Ok, make sure/check for the following (these steps are always to be done for your app export target directory, not the eclipse IDE directory):
Does the RCP Mail Template example work correctly? It should be perfectly possible to create the example app with the wizards and then export via the hyperlink in the first page of the manifest editor. This result should be always working. Otherwise check your eclipse installation.
Did you use the correct launcher? There are eclipse.exe and eclipsec.exe (the latter is the command line version => no splash)
The exported result must contain your bundle in jar or directory form (for our product both forms are working) under /plugins (the bundle itself logically needs to contain your splash.bmp in the root). If I remember correctly it needs to be a BMP with certain parameters. Find them by examining the RCP Mail Template example.
If not: check your product definition (included plugins/features)
Try to use the RCP Mail Template example image for your app. Does it also fail to work? If so, try to open/save with Windows Paint.
Next, make sure your "config.ini" in the configuration sub-folder has the following entry:
osgi.splashPath=platform\:/base/plugins/<your bundle without version appendix>
(osgi.splashPath=platform:/base/plugins/<your bundle w/o version> also works
I don't know if there are any defaults for this setting but maybe this time you should explicitly tell the launcher where to look for the splash image. :-)
Make sure there is no -D parameter that overwrites the config.ini setting in the eclipse.ini next to the launcher (eclipse.exe)
is there a "noSplash" in eclipse.ini or config.ini?
If your bundle is a jar, check if the bmp is correctly extracted somewhere under configuration\org.eclipse.equinox.launcher...
If not: Then the image is not correctly included/found within the bundle jar. Check your build.properties
Delete the workspace and start your rcp app with -clean
Maybe start with -console -consoleLog and -noExit to recognize arising error messages during startup
In my case splash.bmp was 32-bit and it was not shown. After I converted it to 24-bit with GIMP, it was shown (Eclipse 3.7).
I was not added the location of the plugin which contained the splash screen...
Product->Splash->Location->Plug-in
Also make sure that your product dependencies (e.g. in the product editor, tab Dependencies) contains the plugin org.eclipse.ui.intro. Also, you will have to add the extra org.eclipse.ui.intro.universal if your Welcome is based on the intro.universal.
It may be too late , but after following all above steps didn't resolved my problem.Trying below step resolved my problem.
In .prdocut file under Dependencies tab there is a check button "Include optional dependencies when
computing required plug-ins" finally made my splash screen to be visible.
If any one is referring to this answer please make sure you follow above answers and try this answer.