JavaFX 在列表视图中显示字符串附近的图像
问题描述
I want to show a message near a string in a listview i tried to look it up but i cant understand it pretty much i tried this from the website http://docs.oracle.com/javafx/2/ui_controls/list-view.htm at Example 11-4 Creating a Cell Factory i tried to convert it to imageview and it did work but a problem is i dont see a string, the image is not near the string and image is too big there should be a way to resize it soo can someone help me with showing a image near a string in listview? this is the code that i tried to convert:
Piece 1
Piece 2
I hope someone can help me its very important to me. Thanks. If you cant understand what i am asking tell me and i will try to format the question i am bad at explaining problems.
Cells are Labeled nodes which can innately display both text and graphics, where the text is a label for an arbitrary graphic node. So, in your cell, maintain a rendering for the graphic (an ImageView), and set both the graphic and text as appropriate in the updateItem implementation.
Sample Application
Here, all of the possible images are pre-loaded and stored in a cache, which will work OK if you have a small number of images. If you have a large number of images, you would probably want a more sophisticated LRU style cache for the images where newer images are loaded on demand in the background, possibly with a placeholder or progress indicator for the image while the background loading process is running.
In the sample application, the images are resized in the Image constructor so they are all the same height. Also, the implementation is suited to a file type icon display because only a single image for any given file type will ever be created and that same image may be reused via different ImageViews used in different cells.
这篇关于JavaFX 在列表视图中显示字符串附近的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!