Display the ToolTip on the list of colors

Is it possible to display a ToolTip to display the name of the color?

http://S10.postimg.org/94rd93scp/Z034.PNG

Here is my code for the ComboBox color rendering

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Callback;


public class ProvaComboRendering extends Application {
   
    @Override
    public void start(Stage primaryStage) {
       
       
        StackPane root = new StackPane();
        ComboBox<String> cb = new ComboBox<String>();
       
        cb.setPrefSize(150, 20);
        root.getChildren().add(cb);
       
       
        Scene scene = new Scene(root, 300, 250);
       
        primaryStage.setScene(scene);
        primaryStage.show();

    ObservableList<String> data = FXCollections.observableArrayList(
            "chocolate", "salmon", "gold", "coral", "darkorchid",
            "darkgoldenrod", "lightsalmon", "black", "rosybrown", "blue",
            "blueviolet", "brown");
     
      cb.setItems(data);
     
      Callback<ListView<String>, ListCell<String>> factory = new Callback<ListView<String>, ListCell<String>>(){
          @Override
          public ListCell<String> call(ListView<String> list){
              return new ColorRectCell();
          }
      };
     
      cb.setCellFactory(factory);
      cb.setButtonCell(factory.call(null));
     
    }
      static class ColorRectCell extends ListCell<String>{
          @Override
          public void updateItem(String item, boolean empty){
              super.updateItem(item, empty);
              Rectangle rect = new Rectangle(120,13);
              rect.setStroke(Color.BLACK);
              if(item != null){
                  rect.setFill(Color.web(item));
                  setGraphic(rect);
          }
        }
      }  

    public static void main(String[] args) {
        launch(args);
    }        
}

Just add

setTooltip (new Tooltip (item));

in your updateItem method (...).

Tags: Java

Similar Questions

  • How to change the fonts used to display the list of emails on the homepage?

    Looking at my Inbox or other e-mail folder, the font used to display the list of emails in folders - gives me a headache.

    How can I change this font? Is there an add-on? Something in their profile?

    Ideally, I would like to change the background color of white also. (Perhaps the color on this page where I ask the question. "It's easy to read, the font and the color!)

    I've been a programmer in a past life, so I'm tech abreast. I am new to use Thunderbird (I used FF for several years.)

    Thank you!!

    Yes, to change the font, you can use this addon:

    Also, try to use themes:

  • Save dialog box under does not display the list of files

    Terminal Server R2 of 2012.  Dialog box "Save as" for a user does not display the list of files.  The address bar shows the way, there is a form for the file name box, and the user can save the file successfully.  But the space that would show the files in the selected directory is empty.  There is no form for the list of files box, it's just the grey box dialog box space - that is to say, it is not that it looks like an empty folder, there is simply no display form box.

    The 'Open' dialog box appears normal, showing the list of files in the selected folder.

    I had the user close the session on the Terminal Server and access it from another PC, even if I was not expecting to make a difference, and it didn't.  I have also connected on myself and has not experienced the same problem.  So it seems to be user-specific.

    What a setting, the user has selected by mistake, or a mistake any?

    Thanks for any help.

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • How to display the list of components in ultiboard 10?

    The DRC report the errors where the components that are no longer in the design have been removed. How to display the list component and then remove them from the netlist to stop this?

    Ultiboard reported missing errors of component (part 'X' is not about design) because the part is always referenced by a net. To fix this, you must remove the part of the net. Following the steps below to remove the part form the net.

    1 tools > Netlist Editor

    2. for each network that the part has been connected to, select the Net (upper-left).

    3. Select the tab of pine trees, select the part and it is the PIN in the dialog box, then click on remove

    The problem is when the part is removed, I see no easy way to determine the threads you need to remove the part of. I entered this as a feature request to make this easier, but as a workaround, you can put part and say Ultiboard what the missing part, then search the net names on the pins and remove the part of these pins

    1 place a piece with a lot of pine trees (for example the part that was removed, or for example through Hole technology > Connectors > SIL & headers > HEADER2X9). When you place the part, make sure that the RefDes matches the RefDes of the part which has been removed.

    2. once the room is placed, you should see rats nest lines that connect the part to the nets.

    3 Zoom on the pins. You should now see the net name on each of the axes. For each of the pins connected, remove it from the net as described above.

    4. remove the part that you placed.

  • Windows Media Player 12: How to permanently display the list pane

    Windows Media Player 12: Always list

    Hello world

    I've recently updated my computer to Windows 7.

    When I was on XP, the list of WMP 11 component was always displayed in the right part of the screen (except mode full-screen).
    Now WMP 12, I have to manually right-click and choose "View list" whenever I open WMPand whenever a new video starts .

    Could you tell me how to permanently display the list pane?

    Thank you

    Kind regards
    Phil

    There is no way to get or retain the component 'list' in Windows Media Player 12. You must create a playlist to see your playlist.

    I've been playing with this for hours trying to get the same thing your tyring to get.  Microsoft has changed a lot in the Windows Media Player 12 version. The latest version of the windows media player 11 is the only version that can display the playlist pane.

  • EA 4.1 display of version information in navigator slows down displaying the list of tables

    Hello

    I use DM with SVN version control.

    The table browser now displays the icon of overlay on the tables. Nice!

    The version number/log-in / user is not necessary. Maybe an option to display this information.

    In any case the most important question is: now, it takes too long to display the list of tables in the browser.

    Joop

    Hi Joop,

    The version number/log-in / user is not necessary. Maybe an option to display this information.

    Yes, there is an option - "preferences > Versioning > Subversion > General '-' use the navigator overlay State labels.

    The performance - we look at this problem.

    Philippe

  • How to display the list of temporary and free sites that we use?

    Adobe Web Host - Free Sites.

    How to display the list of temporary and free sites that we use?

    When you're connected creative cloud, we used to be able to view the temporary and lots of 5 free sites that we use hoe.

    Could not find a list on my creative cloud account or when the link to 'Manage' in the Muse.

    No mention of the free sites in the FAQ. Is there a change in policy? Are always included in the subscription of the free sites?

    - Adobe Muse help | Adobe Muse / Common Questions .

    When I publish in Adobe Muse CC, must I pay for hosting with Adobe?

    Adobe Muse CC allows you to publish your Web site temporary on the platform Adobe of accommodation free of charge for a trial period of 30 days. This gives you the ability to send a direct URL to your client for review. All sites with Adobe trial mode will include the field "businesscatalyst.com" in it. If you decide to take the live site by paying for monthly hosting, you can transfer your domain name and delete the subdomain businesscatalyst.com. Or you can export the HTML and host the final site with a host of your choice.

    //

    Yes, don't know why they took out of the cloud interface.

    But if you go to http://www.businesscatalyst.com/partnerportal and you connect with your ID cloud you will have access to all your cloud sites and many other features.

  • Is it possible to add thumbnails to display the list of the new model?

    Is it possible to add thumbnails to display the list of the new model?

    Not with the News Module. You have an account that has access to the web apps?

  • How can I display the list of bookmarks on the right side, not the left of the screen of the monitor?

    Display bookmark icon is at the end of the navigation bar. The list of bookmarks arrived by activating the top on the far left that is not practical, because I'm right-handed and I would like to move the cursor down not on the screen.

  • How to display the list on the page all?

    I have a 1 page. In this 1 page, I have a list box. This list to contain three region list.
    each list is a page (page 2, page 3, page 4). When click on any list redirect to the corresponding page, but the region from the list on page 1 does not appear when I redirect page 2, 3 or 4.

    How to display the page list all the 2,3,4?

    SKUD.

    Hello

    create the list in page zero and give the State, saying that all pages will be displayed..,.

    or

    GoTo
    Home > Application Builder > Application xxx > shared components > list of commitments

    Here you can set new pages where you need to see your list

    Kind regards
    Little Foot

  • Create CollectionModel to display the list of objects in af:table

    Hi all

    I CHOSE to use Oracle 10 g with EJB.
    Normally, when I want to view a list of the read data in the database in an af:table, I drag and drop the relevant control data (EJB bean) return object.

    This time, I need to display a java.util.List of dynamically created custom objects in an af:table in the bean managed my the ADF page.
    In order to display the data in the af: table, I need to wrap the data in a CollectionModel.

    I've seen ADF Table through data control CollectionModel Frank Nimphius suggesting to create a POJO where my items list will exist and turn it into a data control.

    However, it does mention how is this possible programmatically.

    Can anyone help?

    Hello

    If you want to create a managed bean model so its just use an ArrayList and provide getter/setter methods. This reference value of the table and the component will ensure that the model works in the table.

    Frank

  • AppleScript: Create logos from the list of colors and hexagonal layer

    I'm writing an AppleScript script that will create a bunch of PNG files of:

    (1) a list of hex colors

    (2) a Photoshop CS4 file that consists of a simple form that uses a logo as a vector mask layer.

    I want to end up with different color versions of the logo - a red, a Meerschaum, one, a burnt sienna, etc. etc.

    So far, I have this:

    each word worth colorlist '002266 005566 006611...'

    destinationFolder value "HD:Logos."

    Tell application "Adobe Photoshop CS4"

    activate

    Repeat with theCurrentValue in colorlist

    -- set the color of the shape layer current in the active theCurrentValue document

    currentFilepath destinationFolder value & theCurrentValue & ".png".

    Save the current document in the file currentFilepath in PNG with options {interlaced: false}

    end repeat

    end tell


    So, how can I change the color of a shape layer?

    How can I specify the color as a hexadecimal value?

    Is this even possible things?

    ----------------

    Finally, it is just me, or is the incredibly obtuse Adobe documentation? Well, maybe this isn't the right word. How about "useless." For example, I searched for hex script reference, but all I found was this:

    RGB hexadecimal color

    A hexadecimal RGB color specification. Hexadecimal RGB color class inherits the properties of color

    value class.


    Properties:

    Property value what it is of Type

    text in Unicode, the hexadecimal representation of an RGB to hex color value

    Well, thank you very much. Sorry to be rude, but that is kinda like 'the copy command copies the selected object.

    That's what I knocked together but I'm not sure what saved Mike because it does not work for me.

    I saved the files but no color change the shape layer.

    Can't really check up on my mac to work where I x Toolkit installed.

    the value Dest_folder to (path to the diskette of starting text) & "logos:

    the value Color_List to {"990000", '005566', '006611'} - a list

    --

    Tell application "Adobe Photoshop CS2"

    activate

    the value Doc_Ref for the active document

    say Doc_Ref

    Repeat with This_Value in Color_List

    the value This_RGB to convert color {class hex color: RGB, hex value: This_Value} in RGB

    the value {R, G, B} to { of This_RGB red, of This_RGB green, blue of This_RGB}

    do javascript "colorToSolidColorLayer (" & R & ',' & G & "," & B &");").

    function colorToSolidColorLayer (color) {}

    ARG var = arguments [0] .constructor;

    switch (arg) {}

    occurrence of table:

    var c = color;

    break;

    case SolidColor:

    var c = new Array();

    c.push (color.rgb.red);

    c.push (color.rgb.green);

    c.push (color.rgb.blue);

    break;

    case String:

    var c = new Array();

    var SC = new SolidColor();

    sc.rgb.hexValue = color;

    c.push (sc.rgb.red);

    c.push (sc.rgb.green);

    c.push (sc.rgb.blue);

    break;

    by default:

    Returns - 1;

    }

    try {}

    var / / desc = new ActionDescriptor();

    Var ref = new ActionReference();

    ref.putEnumerated (stringIDToTypeID ("contentLayer"), charIDToTypeID ('Ordn'), charIDToTypeID ("Trgt'));

    desc.putReference (charIDToTypeID ("null"), ref);

    var modeDesc = new ActionDescriptor();

    var colorDesc = new ActionDescriptor();

    colorDesc.putDouble (charIDToTypeID ('Rd'), c [0]);

    colorDesc.putDouble (charIDToTypeID ("NRG"), c [1]);

    colorDesc.putDouble (charIDToTypeID ("Bl"), c [2]);

    modeDesc.putObject (charIDToTypeID ("Clr"), charIDToTypeID ("RGBC'), colorDesc);

    desc.putObject (charIDToTypeID ("' t '), stringIDToTypeID ("solidColorLayer"), modeDesc);

    executeAction (charIDToTypeID ('setd"), desc, DialogModes.NO);

    } catch (e) {return-1 ;}

    '} ' show the debugger runtime error

    the value \\Server\share\file_path to Dest_folder & This_Value & ".png".

    Save to file file_path in PNG with options ¬

    {Category: PNG save options, intertwined: false} ¬

    don't add any extension with a copy

    end Repeat

    end say

    end say

  • Which component to display the list of words as paragraph?

    Which component is preferable to display a list of words in a paragraph format?

    I have a list of 'tags' (as in the words) in a database, and I want to display the tags in a Flex component as in the HTML example below:
    http://blog.flexexamples.com/tags/

    TileList doesn't work, because the columnWidth is uniform, and the words in the database have variable lengths.
    Thank you very much.

    Hello

    You can do something like this, you can add your additional code in linkHandler function to remove the link to your data source and adding it in the other component


    http://www.Adobe.com/2006/mxml"layout ="absolute">
     
       
                       
    "private var myDataSource:String ="tag1 tag2 tag3"
               
    public void linkHandler(event:TextEvent):void {}
    trace (event.text + "clicked")
    }
    ]]>
       

       
       

  • How to display the list of all the constraints, triggers, procedures... .etc

    Hello
    How to view a list of all the available constraints, triggers, procedures, functions and packages in a database. And how to view its definition?

    user12222356 wrote:
    Not working is this said sql statement "object"sys"". "" DBA_OBJECTS"does not exist"

    OK, so the problem is that you have not allowed access to any data dictionary table. If you want to be able to view all of the DBA_ * dictionary of data tables, you need the ADMINISTRATOR to grant you the privilege to CHOOSE ANY DICTIONARY.

    In the future, when you post an error message, in addition to displaying the error message, it will be useful if you can get the error number, for example, that is, ORA-xxxxx

    Justin

  • Is is possible to display the list of authorized computers (Mac

    I had to re - install iTunes on a PC and when I re-authorized device of the alert stated that this machine was 5 or 5 authorized devices. I think this may be listed several times and this PC to see my list of authorized computers (Mac and PC)?

    You cannot view the list, you can see the number of authorized computers.

    Once every month you can "deauthorise all" (deauthorising a computer does not remove all pleased with himself, he stops just that content used until it was reauthorised account): Deauthorize your computer using iTunes - Apple Support

Maybe you are looking for