JAVA FX ImageView only loads certain images when launched - javafx

I'm currently working on a poker application for fun and I've encountered another issue when trying to work with imageviews.
Right now my structure for my images is the following:
JavaFXApplication1\src\images
that "images" folder contains two more folders, one being "cards" and the other "playerImages".
Here is a screenshot of it also:project structure
Currently I am using a document relative path within scene builder to initially load the images for each of the cards and players. for each of the cards, the imagepath initially is "#..\images\cards\back.png" which is set in scenebuilder. this method works perfectly fine when launching the application. however, for the player images next to the cards, i have "#..\images\playerImages\player1.png" for example and this doesnt work for some reason.
In scenebuilder the "player1.png" image shows up where it should, but disappears when i launch everything.
I read through Images not showing on launch by the main, but showed on Scene builder but Im not not sure the solution for that is the same for me, as my images are in my source folder.
I tried using the fx:id and setting the image manually in my controller class, but was receiving an error stating that my input stream was null.
I also tried just adding "player1.png" to my root images folder and using that path, and that still didnt work. yet, when I change the player1 image path to anything in the cards folder it works. I dont understand why it works for the images in the cards folder but not in the playerImages folder. Both of those folders are in the same location.
I apologize if this was already answered somewhere else and i am too oblivious to see it, but any insight into this seemingly simple problem would be greatly appreciated.

if you have a similar project structure:
--main
--java
--src
--resources
--images
--cards
back.png
--players
player1.png
you can set images from resources in your java-code. But you need to use getResources()
For example:
#FXML
private ImageView imageView;
Image image = new Image(getClass().getResourceAsStream("/images/players/player1.png"));
imageView = new ImageView(image);
Of course directory "resources: shuild be marked as resources root

Related

AEM DAM image replace - references in pages not updating

I have a problem with references to an image not updating in pages that are using that image.
This is the steps that the users are reporting
go to /siteadmin#/content/dam/
on the "new" dropdown menu, select "new file"
select an image file that is a different image but has the same name as a file that already exists
upload the file and when asked that a file already exists, choose replace
activate the file when the upload completes
The problem is that when I check pub I can see the image is updated, and if I navigate to the path of the image, for example:
pub1.mypub:4503/content/dam//my-image.png
I can see the new image I replaced the old one with
the problem is that pages that were referencing the image, specifically the image component, still shows the old image. I've check flush rules, checked workflows and nothing seems to work
The one thing I noticed is that in pages that are referencing the image the path is like this
/content//_jcr_content/my-component/my-component-parsys/columns/parsyscenter/image.img.jpg/1538602163986.jpg
so it seems the path it is using is like a generated path and not the same path as this one: pub1.mypub:4503/content/dam//my-image.png
im at a complete loss, I honestly do not know what else to check, has anyone ran into this and figured out how to fix it?
this is on aem 6.3
the problem is that in pubs the image being referenced in the component does not update, and since it does not update in pub, it never updates dispatcher
You can try activating the referenced pages after the image has been published. Since the page on publish has reference to the previous image.

Complication placeholder not showing

I've just added a complication to my watchOS app. I was able to select it on simulator's watch face, but it shows blank items. Temporary all methods of CLKComplicationDataSource return nil. I've created a new assets group for complication, added all required .png images as specified here, setup Complication Group property in Xcode target, but nothing shows up!
What should I do to enable static placeholder images for my complications?
Configuration in Xcode:
The problem was that the .xcassets file with placeholder images must be included into the watch extension bundle, but it was included into the watch app instead. I spend all day trying to figure this out.

Windows form application - Icon image location?

I think this should be a relatively easy one to answer, I hope, but is proving to be a bit of a stress!
I have used an Icon on an old application developed some years ago and I would now like to use the icon for a current project.. however..
I added the icon using the upload/import icon-image in the properties window, and did not add it in the project resources file, nor specify its location anywhere in my code, using only the icon tool in the properties window.
Now wanting to find the icon image file to use again, I cannot find it anywhere! I have trawled through all the project files looking for the image file or a ref to its location, but have found nothing; except for:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
When running the application the icon is still clearly visible in the applications taskbar tile.
Does anyone know where the icon file is stored / how I can retrieve it?
Thank you in advance.
It is stored in "{Your_project_name}.{Form_name}.resources" file. Search inside the "obj" folder which is in your project folder.
Now open the command prompt of Visual Studio. We will convert this ".resources" file into a ".resx" file. We use "resgen" command here.
resgen foo.resources bar.resx
The .resx can then be added to a C# project. You can find your icon file there.

How do I load dynamic image assets into adobe air

The app I'm working on displays four random images at one point. These four images come from a set of fifty images. If this was a standard Flex project I would just set the img.source property:
this.img1.source ="../assets/img/"+randomname+".png";`
This isn't working though, I'm getting a broken image. One other way to go about it is to load the image with a urlLoader, which is also not loading the image (unsurprisingly, given that it's a local asset)
loader = new Loader();
var urlReq:URLRequest = new URLRequest("../assets/img/"+randomname+".png");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loader.load(urlReq)
So this isn't working either, I'm thinking of loading all of the images into a swc and then linking the swc to the project. This is obviously not great because then all the assets are loaded into memory at runtime. Is there another way of doing this?
I'm hoping that I'm missing something really simple.
If the .swc solution is the best one, can someone point me in the right direction? I forget how that whole business works, as it's been a couple of years since I've worked with Flex/Flash.
Thanks in advance
You should add your asset directories as "source" directories.
Then you should be aware of the fact that the contents of the asset directories will be copied to the root of your application. So when you have the image "assets/interface/bg.png" you should load it using new URLRequest("interface/bg.png").
You may try:
var urlReq:URLRequest = new URLRequest("assets/img/"+randomname+".png");

Flex ItemRenderer Images not appearing at runtime

in datagrid I have an ItemRenderer (which extends UIComponent) which loads images based on a data value, eg:
_img.source = "assets/images/flags/" + value[dglistData.dataField] + ".gif";
When I run my application the images (flags) are appearing in the ItemRenderer. When I build and deploy the application into BlazeDS as an SWF file - the images do not appear. Instead there is the standard "missing icon" link that appears in Internet explorer.
As far as I can tell, my ANT build script includes the above directory "assets/images/flags/" and all the images into the SWF file.
Is this a relative path issue? Not sure, any help would be appreaciated.
Thanks
Mike
When you are assigning a path as source Flash Player is trying to load the images via HTTP requests. Therefore, embedding your images in the SWF has no effect.
There are two possible solutions. Either deploy the folder containing your images to the server and use the corresponding path as your source or embed all your images into the SWF.
A simple example for the second solution. The code assumes that value[dglistData.dataField] corresponds to one of the variables with the [Embed] metadata.
[Embed(source='assets/images/flags/Image1.png')]
private var image1:Class;
[Embed(source='assets/images/flags/Image2.png')]
private var image2:Class;
[Embed(source='assets/images/flags/Image3.png')]
private var image3:Class;
// access the image like this...
_img.source = this[value[dglistData.dataField]];

Resources