get displayed drawable name from imageview - imageview

am trying to create an ImageView that displays various drawable images, i would like to get the drawable name for the image it is displaying. so i nid to control an event based on the drawable name of the imageview. any help? thank you

Related

JavaFX ImageView not refreshing

This relates to JavaFX: I have a 'Products' window which contains a TableView filled with a products list, a few buttons (Edit, Delete, Add, Search) and an ImageView with the picture of the currently selected product (this pic changes correctly on click).
Clicking on the 'Edit' button opens a new window where I can change the image file for the product and correctly saves the new pic to the file system (one note here: the new image overwrites the old one, meaning the image path/filename remains the same).
When I close this 'Edit' window, I clean the picture in the ImageView control by doing:
imageView.setImage(null);
and then I set the "new" image:
imageView.setImage(new Image(path));
Setting the image to null efectively removes the old image, however, the imageView container keeps showing the "old picture" after setting the new one. Is there any kind of chache that needs to be cleaned? How can I "tell" the ImageView container that the image has changed, even though the filename is the same?
Thanks for the help, and sorry for my bad english.
After two weeks I finally found the solution:
Instead of saving the new image using the same file name, I now use a new filename, then update the database table and delete the old file from disk.
Images are not longer loaded using imageView.setImage(new Image(path)); Instead, now I load images using:
File img = new File(pathObtainedFromDatabase);
InputStream isImage = (InputStream) new FileInputStream(img);
imageView.setImage(new Image(isImage));
Thanks to all that tried to help.

JavaFX - How to load a specific AnchorPane's contents from an FXML file?

I'm trying to make an application which switches between scenes back and forth however I need to load a specific AnchorPane's contents into another AnchorPane when the scene switches back. For Example:
In my FXML1, I have a hierarchy that looks like this:
AnchorPane0
----SplitPane
--------AnchorPane1
--------AnchorPane2
In FXML2 the hierarchy is just this:
AnchorPane0
So I load FXML1, then I have a button that switches scenes loading FXML2.AnchorPane0 into FXML1.AnchorPane2. I have a back button in FXML2.AnchorPane0 that needs to load the original scene of FXML1.AnchorPane2 into FXML1.AnchorPane2. Right now my back button loads all 4 containers of FXML1 into FXML1.AnchorPane2. So my questions is, how do I load a specific container's contents preferably without making FXML1.AnchorPane2 its own FXML? Do I need to write a get method for the FXML1.AnchorPane2 to access its contents or is there a way to return an AnchorPane with all of its contents in place already?
I found the solution as shown below:
AnchorPane loader = FXMLLoader.load(getClass().getResource("myFXML.fxml"));
SplitPane spane = (SplitPane) loader.getChildren().get(0);
AnchorPane pane = (AnchorPane) spane.getItems().get(1);
foregroundAnchorPane.getChildren().setAll(pane);

Images from binding not re-appearing properly with ListView scrolling

I have a ListView with an ItemsSource that is a List. The viewcell binds some String properties from MyDataModel to labels as well as an ImageSource property to an Image.
The idea is they click the button, select an image from gallery, and the image in the viewcell changes to what they selected.
That all works fine, until they scroll. When the images go off screen, and you scroll back up to them then all of the images show the same image (the last one selected, or rather the first one that appears when scrolling back up).
I realize that it's unloading the image and re-loading it.. but why isn't it getting it from the correct binding source?
Not sure, if I understand your question correct (without code)...
But if you have a ListView bound to a List with a custom ViewCell and want to change some showed data, the following should work:
- first change the data in the list
- then reassign the ViewCell:
lvXX.ItemTemplate = new DataTemplate(typeof(XXyourViewCellxx));

Printing form created in javafx

I am doing a project in javafx in which we create forms ( forms like admission form etc)
Form contains many labels,textfields (filled with data from database) and some images.
I want to print these labels, data from textfields and the images in the same layout in which they were created ( I mean, after printing textfield1 should not be in front of label2 etc).
Is is possible? or is it possible to convert this form to pdf file so that it could be printed later?
Thanks.
It is possible to take a snapshot of the Scene:
Scene scene;
WritableImage image = scene.snapshot(null);
And then you can save this image in an image format:
http://java-buddy.blogspot.com/2012/12/save-writableimage-to-file.html

Datalist not displaying image from database

My database table contains the image file path I am trying to display that image through a datalist control but the image not displayed the path who displayed
you image path must be in Relative Path format e.g '~/images/abc.png' Now It will work. Thumps Up.
http://www.aspdotnet-example.blogspot.com

Resources