How to change the background color of selection of the selected item in the drop-down box of choice?

How to change the background color of selection of the selected item in the drop-down box of choice?

By default, the selection background color like 'blue', but if I want it to be "yellow" for example, how should I do?

Thank you

The id is applied by (I think) the skin of the ChoiceBox class. You don't need to define.

You must apply the css in an external style sheet. You can apply the external style sheet to any parent of the box of your choice, or on-site (the most usual way to do it).

Example:

import java.util.ArrayList;
import java.util.List;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ChoiceBoxTest extends Application {

  @Override
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Example 2");

    final ChoiceBox choiceBox = new ChoiceBox<>();

    List tempResult = new ArrayList();
    for (int i = 0; i < 10; i++) {
      tempResult.add("Item " + i);
    }
    choiceBox.getItems().setAll(tempResult);

    VBox root = new VBox();
    root.getChildren().add(choiceBox);
    final Scene scene = new Scene(root, 300, 250);
    scene.getStylesheets().add("choiceBox.css");
    primaryStage.setScene(scene);
    primaryStage.show();
  }

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

}

choiceBox.css:

@CHARSET "UTF-8";
#choice-box-menu-item:focused  {
 -fx-background-color: yellow ;
}
#choice-box-menu-item .label {
 -fx-text-fill: black ;
}

Post edited by: James_D

Tags: Java

Similar Questions

  • [bump] How to change the drop-down size menu

    Hello

    I have a menu dropdown and I want to change the size = 4. Where to put it?

    Thanks for your help.
    Jen

    Published by: Jen Hu on April 8, 2013 12:38

    Jen Hu wrote:
    Eric,

    Do you mean: put onload = this.width (300); under attributes of HTML form elements?

    What you're trying to define? size or width?

    Size and width are two different attributes.

    For size add this to your page load

    var resultSelect = document.getElementById ("PX_ITEM_NAME");
    resultSelect.size = 6;

  • Change the drop down CTRL D

    Is there a way to change the drop-down list that appears when you enter CTRL D? I would like to see 10 to 15 lines rather than 5

    Try this extension of the functionality.
    https://addons.Mozilla.org/en-us/Firefox/addon/add-bookmark-here-2/
    The third screenshot shows how to drag the folder listing down to enlarge.

  • How to add the drop-down filter list in a dashboard button/menu

    Hi all

    I created a custom dashboard related activities, but I don't know how to put the drop down filter the list (for example, exercise & fiscal month) on top of the dashboard as Pipeline analysis (report SOD predefined) as well as the button 'Go '.
    Clues?

    Thanks in advance

    Hello!

    In the page analysis of the design, you must create a new dashboard guest.
    Go to Design Analisys, select a report type (doesn't matter which) e.g. addresses of account (1).
    Then on the top left of the page, you will see 3 icons, and the third is new dashboard fast....

    Once you have created your command prompt, you can save it as the other reports, and you can add it to your dashboard.

    I hope this will help, do not hesitate to ask for more!

    Max

  • When I opened the window "save the Page under", the drop-down box file name indicates the files that have been saved a long time ago. It is not cleared by a function 'clear history' that I can find. How can I erase this?

    1. Question

    When I opened the window "save the Page under", the drop-down box file name indicates the files that have been saved a long time ago. It is not cleared by a function 'clear history' that I can find. How can I erase this?

    Hello.

    I think this is a related issue of Windows, because it is the Manager to save the windows file that we are talking about here (right?). You should contact Microsoft for help with this one, I think. You expect to be able to delete entries simply by touching delete on your keyboard when they are concentrated (that is how it goes for the removal of the form entries specific autocomplete in Firefox), but I have not tried.

    I'm sorry I can't be more helpful.

  • How to display the drop-down list box in MS excel by using labview report generation toolkit? pleasepost code block diagram?

    How to display the drop-down list box in MS excel by using labview report generation toolkit? Please post the block diagram of the code so that I can able to generate from the drop-down list box in excel with the menu drop-down...

    Like this. (edition, use the reference forms instead of the reference to the worksheet)

    Ben64

  • How to create the drop-down list box

    Are you able to create a drop down box in Muse? For example, I want someone visits my site have the ability to configure a package by choosing options in the drop-down boxes.

    Here is the exact example that I'm looking.

    http://www.idwholesaler.com/PrimacyExpertSSSystem.html

    Click the OPTIONS tab. You will see the drop-down menu for options, that you must choose boxes.

    THANKS IN ADVANCE!

    This option is not yet available in Muse I'm sure they are working.

    You can use radio buttons.

  • When we choose the radiobutton control should display the drop-down list of choices...

    Hello

    Can u help me pls how to get the drop-down list option when we choose control radiobutton in the same screen.

    When deselect us it, he must hide the drop on the with on screen no matter what accent...

    Thanks in advance...

    u r Correct.

    Acutally we work on popupscreen with transparency.

    I use the 4.3 sound support for setmargin(4.5 doesn't).

    I went through the doc 4.5 Finally I got the result.

    I need to set the drop down just below the dropdown list how can I without no hardcode... pls let me know...

    now iam using setmargin (encode);

    If you have any advice that can help me in pls reffer me programming skills.

    I wil get u was pushing for the next...

    Thank you for your way of orientation...

  • get the index of a selected item in a drop-down list box

    Hello

    If I have a list of strings in a drop-down list box and the user selects one in the drop-down menu, how can I get the index?  I was able to explore the table for the selected channel, but it seems like duplication of effort to create a list and then go back and research it.

    Thank you

    Brendon

    It's easier to change control of the ring or Enum which gives the index as a default value, a drop-down list box gives a string that must be converted. But if you like really graphic and you want to use the drop-down list you can uncheck the "use strings as values" option and enter the index as numbers and then make a string to Decimal conversion.

    /Y

  • How to get the drop-down menus to insert the time in format 24 hours a day instead of 12-hour format?

    Need help with form that inserts a time defined by the user in a new record using the drop-down list three menus, php 5.3 and mysql on OS X system.


    I have a problem of formatting the values inserted in 12-hour am/pm time format in mysql time 24 hours format. I don't know how or where to do the necessary changes. I use a Web script that works as required, with the exception of conversion on the issue of the time.


    I tried to format time in mysql using DATE_FORMAT and TIME_FORMAT, change formatting using php, using another function to add 12 hours, using advice from various forum posts, using a hidden field and reorganize the content of the page, but I am unfortunately too inexperienced and awkward in the areas involved to shoot successfully it all together; Instead, I just managed to confuse me and make hash of the encoding.


    The code on the page works (inserts in the mysql database) but not inserts do not pm time. The mysql field is a basic time with a default value of 00:00:00. I have need the date as the time lists are especially necessary for planning purposes unrelated to any specific date.


    I would appreciate help, ideas, pointers or ideas is at work. It is a new area for me. Thank you.

    Parts of code:

    $hours = ' < select name = "time" > "'. ' \n';"

    $minutes = ' < select name = "min" > "'. ' \n';"

    function check ($num)

    {

    If ($num < 10 & & strlen ($num) < 2)

    {

    $num = '0'. $num;

    }

    return $num;

    }

    for ($i = 0; $i < 13; $i ++)

    {

    $hours. = ' < option value = "' check ($i)." » » >'. $i. "< / option >". » \n » ;

    }

    $hours. = "< / Select >.

    for ($i = 0; $i < 60; $i += 5)

    {

    $minutes. = ' < option value = "' check ($i)." "" ">"check ($i). "< / option > '. » \n » ;

    }

    $minutes. = "< / Select >.

    If (isset($_POST['submit']) & & $_POST ['submit'] == 'Submit')

    {

    echo ' the time that you entered is: ';

    $hour = $_POST ['hour'];

    $min = $_POST ['min'];

    $ampm = $_POST ["ampm"];

    echo date (' h: i a ", strtotime ($heure.': '.)") $ min. ' '. $ampm));

    echo "< hr > ';

    }

    ? >

    Insert and query the Recordset:

    $insertSQL = sprintf ("INSERT INTO endtimelist (EndTime) VALUES (%s)", GetSQLValueString ($_POST ['time']. ':'.) ") $_POST ['min']. 00', 'date'));

    $query_rsEndTimeList = "SELECT EndTimeListID, EndTime, TIME_FORMAT (endtimelist.» End time, "(% h: %i %p ') AS EndingTime FROM endtimelist ORDER BY EndTime ASC"; "

    Form:

    < form action = "<?" PHP echo $editFormAction;? ">" method = "POST" name = "endtime" id = "endtime" >

    Time: <? PHP echo $hours;? >: <? PHP echo $minutes;? >

    < select name = "ampm" > < option value = "am" selected = "selected" > AM < / option > < option value = "pm" > AM < / option > < / select > < br >

    < input type = "submit" name = "submit" value = "Submit" >

    < input type = "hidden" name = "MM_insert" value = "endtime" / >

    < / make >

    There is nothing wrong with your brain. You did it very well. Is to forget the details such as 12 noon and midnight, causing stupid errors of logic in the code.

    The book, I plan to write will be about Dreamweaver and PHP, covering many aspects not addressed is not my course books. I expect to publish by May next year, but there have been unforeseen delays, it is not likely to be interrupted until June or July. Writing a book is a tedious exercise.

  • How to use the drop-down list box to fill in a text box

    I'm a beginner when it comes to Java Script.  I have seen a lot of different discussions, look at a lot of articles "helping" Acrobat 9 and Java Script, but only to be left confused and dazed.  I hope someone can tell me how to write a script that fills a text box that sits on my form with the value of exports of the selection in the combo box...

    Thank you

    If you want that the read-only text box, simply set with the following custom calculate script:

    Set this field to the value of the drop-down list box

    Event.Value = getField("combo1").value;

    but replace "combo1' with the actual name of the combo box field.

    If you want something else, post again with more information.

  • How to fill the drop-down list components installed?

    I have installed Eclipse and the blackberry for eclipse plugin that includes the component pack 4.5.0. I have installed all of the components listed on this page: http://na.blackberry.com/eng/developers/javaappdev/javaeclipseplug.jsp. The versions 4.2.1 and 4.3.0 are zip files that I add to Eclipse by using the software update-> add the site-> archive. Version 4.6.0 and 4.6.1 4.7.0 are exe files that settle in the location C:\Program Research In Motion\BlackBerry JDE component Package 4.x.x.

    In the folder plugins on the box, I see version 4.3.0 and listed 4.5.0 4.2.1. When I go on Blackberry JDE-> installed components and click the drop-down list box, the only pack component that I see is 4.5.0. How do the other components packs appear?

    Well it's resolved, I guess. After about 3 hours, the software updates-> add the site-> repository for the Blackberry update works. When I installed the components as a result, they appear in the drop-down list. It's a little confusing, because I already tried this at least 5 times and each time before eclipse was a java error when doing this.

  • How to organize the drop-down menus page in Web analysis report

    Hello Experts!

    I created a Web based on my Esssbase cube analysis document. This document contains a grid with 7 drop-down menus. All dropdowns are in a line from the top and they are narrowed so that all they are part of line 1 in the screen and I can't see the full names of the members in a drop-down list. So I need some advice on how I can arrange drop-downs in my Web analysis report so that I can see the full names of members at the opening of the drop-down list? Thank you very much!

    Hello
    Try to open the report in designer Mode and adjust the width.

    Concerning
    SNK

  • show/hide fields based on the drop-down list of choices

    I have a field from the drop-down list with three choices. Based on the selection, I need a specific text form field to appear and the others to stay hidden. (Or if it makes the code cleaner, the resulting field could be a drop-down list, too, with the selected choice.) I don't know Java well enough to extrapolate the code from the examples online and it fit my forms. I can provide an example of form. Thanks in advance for your help.

    There are ways to run this.  the easiest for you would be to add this script to the event (calculation of the Properties tab) to calculate the field that must be hidden.  Take notes, all "/ /" is some tips for you to understand the code.  You will need to put this script in all the areas you want to replicate the behavior, change the value depending on what you want to accomplish.  the word 'event' means myself to make you understand.

    If (this.getField("dropdown").value == 'put value here') {//replace "drop down" with the name of the drops}

    Event.Target.Display = display.visible;

    }

    else {}

    Event.Target.Display = display.hidden;

    }

    This works if you have a small amount of fields.  If you manage to have a large number of similar fields, let me know because there are other, faster ways.

  • Activity Code values are not displayed in the drop-down list of choices

    I added a P6 activity Code (seller) and added some code values it contains. I'm in a position successfully, choose this option in the selected columns list, but when I go to select a value from the drop down, no values are displayed.

    Advice on why this happens or how to fix?

    Thank you
    Bill

    Published by: user12451419 on 18 June 2012 10:47

    When you assign a code by clicking on the column, a window opens. At the top of the window, click on the view bar, and then choose filter by > all values.

Maybe you are looking for

  • Firefox don't remember how I specified.

    Whenever I want to use Firefox it does not account for the homepage, mail2world.com, I put. I run Windows 19, and I guess I'm not quite used to rhat one yet. Windows XP was MUCH better!

  • Satellite P200D-128: Toshiba has a Web page for the graphics card drivers?

    Hi I want to update the driver for my card graphics ATI Mobility Radeon 2400HD with the updated driver, Toshiba has a Web page for the graphics card drivers? Concerning the best and warmAdrian Wainer

  • Microphone issue on my Satellite Pro P300-23F

    Hello!I have the problem, every time when I plugin my headset my sound no longer works, but the microphone works fine, I tested it with Skype. I use Vista x 64. Greeting

  • Tecra M9 and Express Port Replicator - display flicker

    Hi guys,. I'm having some problems with my new Tecra M9! After that laboriously installed all the drivers and ending up with a nice clean install, I am now subject to constant headaches! I run a Setup dual monitor with my main monitor being a LG 19 "

  • Computer does not print

    I installed Windows 8.1 on my HP computer and now my computer will not print.  It's the only thing that has changed, it is connected to the internet, everything else seems good.  My computer is offline.  Can you tell me how I can solve this problem?