Problem in choice box

i have a choice box whic display from 0 to 59. when i cselect the choice box it display from top to bottom of my screen . how will i make it look only 5 items when it displays.
here is my code. pls help
final ChoiceBox minitueChoice = new ChoiceBox();
        minitueChoice.autosize();
        minitueChoice.setItems(FXCollections.observableArrayList(
                "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"));
        minitueChoice.getSelectionModel().selectFirst();

Hi,
I hope the ComboBox is a better option for this case.
final ComboBox<String> minitueChoice = new ComboBox<String>();
minitueChoice.autosize();
minitueChoice.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
          @Override
          public ListCell<String> call(ListView<String> paramP) {
               paramP.setMaxHeight(146); // To show list view till 5 options
               return new ListCell<String>(){;
                    @Override
                    protected void updateItem(String paramT,boolean paramBoolean) {
                         super.updateItem(paramT, paramBoolean);
                         if(!isEmpty()){
                              setGraphic(new Label(paramT));
minitueChoice.setItems(FXCollections.observableArrayList(
                "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"));
minitueChoice.getSelectionModel().selectFirst();Regards,
Sai Pradeep Dandem.

Similar Messages

  • Bind an object to a choice box

    Is there a way to bind a list of objects to a choice box or at least a name value pair?
    For instance, I have a drop down that lists the user roles. Each role has a specific id.
    Now in my FXML I would like to display the role on the screen, but however when user selects a role, I would like to see the role id in my action method.
    This is how my FXML looks:
    <VBox fx:id="vboxInner" spacing="30">
        <children>
         <HBox spacing="30">
             <children>
              <Label text="*Password:" prefWidth="115.0"/>
              <PasswordField promptText="Password" prefHeight="30.0" prefWidth="200.0" fx:id="password" />
             </children>
         </HBox>
         <HBox spacing="30">
             <children>
              <Label text="*Repeat Password:" prefWidth="115.0"/>
              <PasswordField promptText="Repeat Password" prefHeight="30.0" prefWidth="200.0" fx:id="repeatPassword" />
             </children>
         </HBox>
         <HBox spacing="30">
             <children>
              <Label text="*User Role:" prefWidth="115.0"/>
              <ChoiceBox fx:id="userRoles"></ChoiceBox>
             </children>
         </HBox>
         <Label text="* indicates mandatory" textFill="red"/>
        </children>
    </VBox>And my controller:
    @FXML
    private ChoiceBox userRoles;
    @Override
    public void initialize(URL location, ResourceBundle resources) {
             userRoles.setItems(retrieveUserRoles());
    private ObservableList<String> retrieveUserRoles() {
         ObservableList<String> userRolesList = null;
         try {
             ServiceLocator serviceLocator = ServiceLocator.getInstance();
             LoginAuthenticateSLBeanRemote loginRemoteBean = serviceLocator.retrieveLoginAuthenticateEJB();
             ArrayList<UserRole> roles = loginRemoteBean.retrieveUserRoles();
             ArrayList<String> strRoles = new ArrayList<String>();
             for(UserRole role : roles){
              strRoles.add(role.getUserRole());
             userRolesList = FXCollections.observableArrayList(strRoles);
             Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, "Roles Size::{0}", roles.size());
         } catch (Exception ex) {
             Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
         return userRolesList;
    }UserRole object contains both role and roleId.
    Any hints on implementing this would be highly appreciated.
    Thanks.

    Thanks jsmith.
    overriding the toString method took care of my problem and I can now bind my entire object to the dropdown item.
    Thanks.
    jsmith wrote:
    You can see an examples of doing something similar to this (without fxml) here:
    https://gist.github.com/1422104 "JavaFX ChoiceBox control backed by Database IDs"
    A previous thread discussing this is:
    ChoiceBox  containing 2 values
    On the thread Richard also suggests "What about using a custom selection model that has methods on it to select an item by id or by name?" which is a route I haven't explored.
    For JavaFX 2.1 there are some new implementations which may assist this task (both of which I haven't really used, so I can't really advise on them):
    1. StringConvertors which can be applied to ChoiceBox items
    2. More functional ComboBox control.

  • OS/2: Choice box not painted

    I am obliged to develop an applet for JDK 1.1.7 running on Netscape 4.x on OS/2. I have a strange problem where a Choice component does not display on OS/2 (its paint method never gets called), while the same code works just fine on Windows under either Netscape or IE.
    I am implementing a simplified version of JTable that displays data in tabular form and may contain a single editor field to edit the currently selected cell. The table class sets its layout to null and positions its single component using Component.setBounds(). The component is positioned in the table at the location of the currently selected table cell. When the editor component is a java.awt.TextField, it displays just fine. When the editor is a java.awt.Choice, it does not get painted.
    Obviously, since I haven't posted any source code, I don't expect someone to tell me exactly where my problem is. I'm just looking for people to think back to their OS/2 development days (hah!) and see if they remember any gotchas related to Choice components. The funny part is that this Applet uses Choice components successfully elsewhere.
    This appears to me to be a bug in the OS/2 VM. I have already encountered legions of other incompatibilities between Java running on OS/2 and on other operating systems.

    Well, I've sort of answered my own question.
    The picture is slightly more complicated than I described in my original post. The editor component for the table is contained in its own small Panel, the exact dimensions of the table cell. The Choice box fails to paint if the small panel's layout manager (1) forcibly changes the Choice's dimensions to be smaller than it prefers, or (2) lays out the Choice such that its dropdown button would not be visible due to cropping on the right side of the component. Thus, the Choice displays if the Panel's layout is Border, and the Choice occupies the EAST area, but not if it occupies the CENTER or WEST area. If I set the Panel's layout to null and manually position the Choice to (0, 0) and set its bounds to the size of the cell, it doesn't paint.
    This sucks because visually it won't work to truncate the left side of a Choice box, and I can't shrink it without it disappearing, so that puts my table layout at the mercy of whatever strings are contained in the Choice list. I read those from a database.
    At this point I am strongly considering writing my own Choice component.
    Let me just take this opportunity to fart in the general direction of the people who developed the Java runtime for Netscape on OS/2.

  • My iTunes choice box is blank.

    I push my iphone on USB and itunes can't seem capacitance icon, and any choice box icon is blank, I can't choice anything.
    Who can me why? thank you so much.

    If anyone else is having this problem this answer worked for me:
    >Start Menu
    >Accessories
    >Right click on the command prompt and click "run as an administrator"
    Once it opens, type in the following command...
    netsh winsock reset then hit enter
    You should get a message that the winsock reset sucessful and you will need to reboot your computer

  • Choice box flicker on Linux?

    Hi,
    We have started using the preview MenuButton control as well as the ChoiceBox. Unfortunately, both of them suffer from flicker problems on Linux OS. The moment you move from one menu item to the other, the whole menu redraws which causes a bad flicker. This however does not happen on Windows.
    Any suggestions on how to overcome this flicker? Our target runtime is Linux and we have hit a block!
    Thanks,
    Dhruva Ray

    Thanks Jonathan...Good to get a prompt response from you! I will file in the bug. Some more investigations to help you reproduce the problem
    The bug is pronounced if you add more items in the choicebox. Around 5-6 strings in the choicebox should be good enough to see the flicker clearly. If you move the mouse up and down over the various items, you can see the flicker clearly.
    My Machine config:
    1. Ubuntu 10.04. It appears with earlier versions of Ubuntu as well
    2. Windowing manager : GNOME with compiz
    3. Set System->Preferences->Appearance->Visual Effects->Normal
    To avoid the background white rectangle below the choicebox.(or menus) [See  [http://blogs.sun.com/tor/entry/transparent_windows_on_linux] ], I needed to do 2 things
    -Set Visual Effects (step 3) as described earlier
    -Set stage transparency to true ( "javafx.allowTransparentStage")
    So the resultant snippet is
    Snippet 1
    java.lang.System.setProperty( "javafx.allowTransparentStage",  "true" );
    Stage {
        title: "Application title"
        scene: Scene {
            width: 250
            height: 80
            content: [
                ChoiceBox{
                    items: ["1","2", "3","4","5", "6"]
    }To get some more info about what is hapenning beneath the scenes, I ran the program with -Dsun.java2d.trace=log set
    This gave the following output in the console when I move the mouse over the items in the choicebox
    sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntArgbPre)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntArgbPre)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntArgbPre)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntArgbPre)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntArgbPre)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntArgbPre)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntArgbPre)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntArgbPre)Now I ran the same code snippet with with -Dsun.java2d.trace=log set but did NOT set the javafx.allowTransparentStage property. In this case the white rectangle comes behind the choicebox :( (And hence we cannot NOT go with approach), but there is NO flicker when I move my mouse over the choice box items
    The dump in this case was
    sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.MaskFill::MaskFill(AnyColor, SrcOver, IntRgb)
    sun.java2d.loops.DrawGlyphListAA::DrawGlyphListAA(AnyColor, SrcNoEa, IntRgb)
    sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)It appears from the dump that there is an sandwiching Blit operation when there is no flicker. Does this give any clue? Or am I barking up the wrong tree?
    Thanks
    Dhruva Ray

  • My TV is mounted on a wall so I can't connect the Apple TV device. Is it possible to connect to an HD Cable Box and send signal to TV that way? Other problem is that Box only has one HDMI socket .. Help!

    My TV is mounted on a wall so I can't connect the Apple TV device. Is it possible to connect to an HD Cable Box and send signal to TV that way? Other problem is that Box only has one HDMI socket so would also have to use a splitter. Tried Apple Support but couldn't offer a solution. I can't be the only person with this issue surely?
    Help!

    No, unless you are using a home theatre system already, your only option is to connect to the TV.

  • How to match the width of the choice box's dropdown to the choice box

    Hi there,
    I'm using a ChoiceBox control. The choice box seems to be composed of two parts: the box(displaying the current selection) and a context menu(dropdown). What I find strange is that the dropdown of the choice box(the context menu) has different size than the choice box by default:
    http://manvox.com/javafx1.3/choice-box-dropdown.jpeg
    I can style the choiceBox's box element by modifying the +.choice-box+ CSS selector. I can also style the dropdown using the +.context-menu+ and +.menu-item+ selectors.
    How can I ensure that the dropdown has the same size of it's parent choice box and is aligned to it?

    @alabala: Please, if you can spare a few minutes, can you file a bug report for this at the JavaFX Jira issue tracker here: http://javafx-jira.kenai.com
    If you set the 'project' to 'runtime', and 'component' to controls, it'll end up on my desk and I'll get the owner of the ChoiceBox control to take a look at it.
    Thanks,
    -- Jonathan

  • I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    You are absolutely right.  Thought Enter meant Enter.  I was wrong.  Thank you for the help.
    Rod Rogers, Broker
    Accredited Land Consultant (ALC)
    Metcalf Land Company, Inc.
    Office: 864-585-0444
    Mobile: 864-316-0297
    Fax: 864-583-6000
    <http://www.metcalfland.com> www.metcalfland.com

  • Firefox will not start in normal (hour glass for a second) or in safe mode (closes after choice box).

    Firefox will not start in normal (hour glass for a second) or in safe mode (closes after choice box).
    I tried all of the following with no success:
    - uninstalling and reinstalling mozilla with no success.
    - End all firefox.exe from the task manager and then open again the firefox from quick launch or desktop or program files folder.
    - Change the firefox.exe name to firefox2.exe
    - Start in safe mode and choose several alternatives after choice box, but nothing happen.
    Please help.

    What is your computer system, and what Firefox are you using?
    Start your '''Computer''' in safe mode. Then start Firefox. Try '''Safe''' web sites.
    '''[http://encyclopedia2.thefreedictionary.com/Linux+Safe+Mode Starting The Computer In Safe Mode;<br>Free Online Encyclopedia]'''

  • Problem in Virtual Box

    I have a problem in Virtual Box
    Which I can not use any Virtual System
    Set everything you asked the wrong window
    But stayed the same problem
    This is a picture of the problem
    http://im32.gulfup.com/HdUpE.png
    Last edited by Haithem (2013-06-12 17:24:42)

    karol wrote:
    jasonwryan wrote:Don't bump your posts: https://wiki.archlinux.org/index.php/Fo … te#Bumping
    If you're refering to 'Please', he may have meant 'Here you go' and if so, it was meant as a response to ewaller's post about the thumbnail.
    karol, perhaps you  should read the link I posted.
    Not an installation issue: moving to NC...

  • How can I place multiple choice boxes on the same line instead of in a column?

    I know it is possible to place multiple fields on the same line, using drag and drop.
    But to save space, I would like to have 3 or 4 multiple choice boxes next to each other on one line. 
    Is this possible, and if so, how?
    Thanks
    Peter

    You may click on the "+" button to the right of the first multiple choice box to add more in the same line. When you hover over the button, the tooltip says "insert item beside".

  • How to change the selection background color of the selected item in the popup menu of the choice box ?

    How to change the selection background color of the selected item in the popup menu of the choice box ?
    By defaut, the selection background color likes "blue", but if I want it to be "yellow" for example, how should I do ?
    Thanks

    The id is applied by (I think) the skin class of the ChoiceBox. You don't need to define it.
    You have to apply the css in an external style sheet. You can apply the external style sheet to any parent of your choice box, or to the scene (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<String> choiceBox = new ChoiceBox<>();
        List<String> tempResult = new ArrayList<String>();
        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 ;
    Message was edited by: James_D

  • HT3529 Problem in message box

    I am facing a new problem in message box i.e, some messages are showing in list but while viewing them they are being blank &amp; deleting... This issue is after updating iphone4 with iOS 6.0 please give solution

    it's not working yaar. I'm getting one errror while using "this" instead of "null"

  • I'd like to create 2 choice boxes in applet, how can I can it ?

    I have done a choice box in applet like this:
    Panel p2 = new Panel();
    p2.setLayout(new GridLayout(3,0));
    choice.add("Leftfoot");
    choice.add("Layer1");
    choice.add("Layer2");
    choice.add("Layer3");
    choice.add("Layer4");
    choice.add("Rightfoot");
    p2.add(choice);
    This choice box shows all components of a furniture, but now I'd like to add another furniture in the applet, and it also has several different components. I want that when user selected the furniture name in first choice box, then the second choice box will automatically and only shows the components the furniture u selected has. so how can I make the actions between the 2 choices. Thanks in advance.

    look at the function addItemListener in choice and then look ate the interface ItemListener.

  • Fire a function from a Choice Box selection

    I can't seem to figure out where to place code to create an event when the user selects a choice from a Choice Box:
    def theChoice = ChoiceBox {
         items: ['one', 'two''],
    function MySelect(){
    if(theChoice.selectedIndex == 1){
    println("test...");
    As far as I can tell, the Choice Box control has no "action" variable (like a Button object) so I'm not sure how to like an event to a selection....
    thanks

    Lol, you beat me by a few minutes! :-D
    To be more precise, Button has no state we can override to detect the action, hence the specific callback. While ChoiceBox has several states (selectedIndex, selectedItem) and can have others in the future (eg. in an editable choice box).

Maybe you are looking for

  • Windows XP on Macbook Pro - Control Panel settings

    I've been a Windows user for years, and now find that I still require my Toshiba laptop on my desk beside my Macbook Pro. My problem today wih the MBP is problems while in Windows XP with the Control Panel. I continually reset the regional time zone

  • Anyone knows how to change to port 21?? please hel...

    Hi, I am trying to enable port 21 on my BT home hub manager online and i don't seem how to do it. I have rung bt 3 times today and been diverted to india where they know F*** all. They said this is a tech issue/problem which i know it isn't. It only

  • MAC driver for HP Pholtosmart C4200

    How do I get a download from Apple to allow HP Photosmart C4200 for my Snow Leapard

  • Use Any Song As An Alarm?

    Hi, With the iPhone, is it possible to use any Song as the sound for an Alarm that you've set? If not, why not? I understand the restrictions with Ringtones, as Ringtones have their own industry. But there's no industry for Alarm Sounds, is there. So

  • Looking to create delivery with multiple batch line items

    Hi,    Can you please suggest me BAPI / FM to create a delivery with multiple batches. like ... i have 1 mail line item in the delivery and n sub line items. If possible can you please post req parameters too. Thanks in advance.