How to correctly customize the text label of a JavaFX ComboBox

Hello

from Swing to 8 JFX, I'll try to find out how to do something I would normally do in a single super ListCellRenderer, i.e. to customize the string that is displayed for an item. I tried this:

ComboBox<Integer> combo = new ComboBox<>();
    combo.getItems().addAll(1, 2, 3);
    combo.setCellFactory(new Callback<ListView<Integer>, ListCell<Integer>>() {
        @Override
        public ListCell<Integer> call(ListView<Integer> param) {
            return new ListCell<Integer>(){
                @Override
                protected void updateItem(Integer item, boolean empty) {
                    if(item != null)
                        setText("#" + item);
                }
            };
        }
    });

However, when I do this, the custom string is not used for the selected item (rather the toString() standard value of the element). Apart from that, it is more selectable with the mouse (I submitted a bug report for this to https://javafx-jira.kenai.com/browse/RT-37445), but this isn't really the point of my question.

What Miss me? Is not the way to do it? The thing I have to do to make sure that the selected item is also rendered using the custom cell or is there a different mechanism for that?

Thank you

Robert

There is no bug here (in the API, there are some bugs in your code). The question of the selection is because you call implementation of the superclass of the updateItem (...). The display of the selected item is controlled by the button cell, not the cell factory. If you have the permissions to do so, it might be useful to retract or close the jira.

Tags: Java

Similar Questions

  • How can I customize the texts ADF resource bundle (labels etc.)

    I have a request put in place for the customization of MDS, and customization works (changing field order, removing fields, changing the validation etc.)
    My challenge remaining is how to customize text in UI (labels, error messages from validation).

    When I run JDeveloper in customization developer mode, the 'label' property and other texts of the user interface are grayed out and not customizable.

    It seems obvious that it should be possible to customize the user interface labels. For example, the same field could be called 'Customer number' organisation, "Partner ID" by another and "Membership number" by a third party.

    I can't find anything on this in the documentation (I read ch 34 of the dev guide). Can someone shed light on the question of whether this is possible?

    Best regards

    Sten Vesterli

    Sten, this section of the developer's guide help?

    34.2.6 How to enable customizations in Resource Bundles: http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/customize.htm#sthref2733

    Blaise

  • How can I customize the navigation bar in Firefox 29? I wish I had the back refresh/stop button in front of the navigation bar!

    How can I customize the navigation bar in Firefox 29? I wish I had the back refresh/stop button in front of the navigation bar!

    One of the developers has been around the forum recently try to answer some of these questions then I quote the developer

    For the entire quote and useful links for corrections and explanations please see

    Each setting you see in a computer program you use requires work; when a developer wants to build something new or improve something, he or she has to go through each related (hidden) setting and test if it still works like before and do that on each platform Firefox runs on. That's Apple's Mac OSX, various flavours of Linux and various flavours of Windows, including Windows XP. This costs time, lots of it, and that amount grows exponentially with each setting that's added. This comes on top of our work to continuously fix, improve and innovate Firefox.
    
  • How can I customize the size of the words of captioning?

    How can I customize the size of the words of captioning?

    Captioning has certain restrictions, in terms of size of police and of the variety, but it can be a good thing when you expect your subtitles to decode correctly on the Galaxy of possible volumes, on which it might be necessary to display. So, there are some compromises with captioning.

  • How can I change the text of 'Back' and 'Back' links

    Hello world

    How can I change the text of the standard 'Return' and 'Back' links that appear to the low ratio when the user explores?

    I need to change it in the interface of Hebrew.

    Thanks in advance,
    Alex

    You must customize the viewmessages.xml file. The path to the original file for the English language is

    oraclebi\web\msgdb\l_en\messages\viewmessages.Xml.

    and the entries for the back and back are

    Previous

    Return

    For more, cusotmization language, read the oracle, not page no 197.

    http://download.Oracle.com/docs/CD/E10415_01/doc/bi.1013/b31766.PDF

    -Madan

  • How can I change the text in the Messages to the vertical?

    How can I change the text in the Messages to the vertical?

    If you mean change the orientation, simply turn the phone. If this does not work, close Messages and then run again.

    To close the Messages, press the Home button twice quickly. You will see small glimpses of your applications recently used. Drag to the left to find the application you want to close. Swipe up on the preview of the application to close.

    If it does not, the strength to restart the phone. No data is affected by this. To force the reboot your device, press and hold the two buttons of sleep/wake and home for at least ten seconds, until you see the Apple logo.

  • How can I remove the text in the Favorites toolbar so it's just the icons

    How can I remove the text in the Favorites toolbar it just the icons so they will all fit on one line and are visible

    See:

  • How can I customize the toolbar when you use the browser of the attribute

    In CVI 2012, changes in the toolbar depending on the environment, for example, it is different to the source window and the user interface editor. The toolbar can be customized using the Options menu / toolbar...

    Unfortunately, when you use the browser of the attribute of the user interface editor, another toolbar is displayed, i.e. not the UI Editor toolbar... I would have assumed that the browser of the attribute belongs to the user interface editor, obviously this isn't... So, how can I customize the toolbar when you use the browser of the attribute?


  • How can I customize the thumbnail that is displayed next to the URL in the browser?

    The use of MUSE to create my site, how can I customize the thumbnail that is displayed next to the URL in the browser?  Also, how can I customize the thumbnail image that appears during the incorporation of the site link in things like Facebook?

    Automatic thumbnails are used... I do not understand how they are drawn and how do I customize Muse.

    The thumbnail is the brown box here:

    Screen Shot 2016-04-06 at 8.28.48 PM.png

    The thumbnail is the white box here:

    Screen Shot 2016-04-06 at 8.30.04 PM.png

    Hello

    You can do this by adding Og tags for Facebook share and favicon.

    To apply a favicon in Muse, please go to file > Site Properties > Content and apply the favicon.

    Adding images to Facebook Share, please see a similar thread below.

    When I share the link to my site on Facebook or other social media, the preview image is empty, there is nothing there anyway to solve this problem?

    Kind regards

    Vivek

  • How can I change the text independently copied element?

    Hi, if I copy a text element, and then insert it, change the inserted, also changes the original text element. How can I change the text independently copied element? Thank you! The German Adobe Web site have no idea on the copy and paste text elements

    [title published by mod]

    It's because you copy the title, which creates a clone. Change and it changes the other.

    As I show in my book, Amazon, what you really want to do is title duplicate in right-clicked on it in the components panel of project and selecting two copies.

    A duplicate makes a copy of the title, but this copy is independent and any changes that will make her to this single copy.

  • How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    Hi all

    How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    There is also a checkbox on the dialog box 'Sign' to lock document after signing.

  • How can I incorporate the text search when a project public captivate in HTML5?

    How can I incorporate the text search when a project public captivate in HTML5?

    There is an option in the skin editor > TOC settings, but I think you will find this only applies to research on the names found in the table of contents itself, not the entire project.

  • How can I make the text in the image, like a signature in a corner?

    How can I make the text in the image, like a signature in a corner?

    Do you need to do it for a lot of pictures?

    Look closely.  It should be under file > processing of multiple files.  Make sure you don't overwrite your original files.

    If a single file, make a copy of the file, create your image in a separate layer and reduce the opacity.  Then flatten image and save it.

  • I have a form in which the text area can be developed to accept more text, but the text does not appear on the printed copy.  How can I get the text to print?

    I have a form in which the text area can be developed to accept more text, but the text does not appear on the printed copy.  How can I get the text to print?

    Hi robinm6200,

    Make sure that you have selected 'Document and annotations' under 'Comments and forms' when printing.

    Kind regards

    Nicos

  • DC as a sentence installed and I can't find anything! How do I highlight some text in the box, how can I change the text color?

    DC as a sentence installed and I can't find anything! How do I highlight some text in the box, how can I change the text color?

    Hi taraf32044550,

    I think the new user interface can be a bit of a learning curve, but I hope that you really like it when you find your bearings. Please check these tutorials will help you to find your way around: Acrobat DC Learn & support.

    In particular, I think that you will find this tutorial very useful: change text and images in PDF files

    Best,

    Sara

Maybe you are looking for