Results 1 to 4 of 4
  1. #1
    ghansham is offline Member
    Join Date
    Jul 2013
    Location
    South America, Guyana
    Posts
    12
    Rep Power
    0

    Default Javafx - ComboBox

    Hi Everyone. Hope someone can help me.
    I have issue with combo box. After adding a Text object to a combobox the item in the list is not visible after selecting it twice. With the other item in the picture, the same happens and the entire list is not visible.
    When you use strings without the Font style everything is fine.

    Java FX Code:
    Text text1 = new Text("Text 1");
            text1.setFont(Font.font ("Verdana",FontWeight.BOLD, 20));
            Text text2 = new Text("Text 2");
            text2.setFont(Font.font ("Verdana",FontWeight.BOLD, 20));
             
            ComboBox combo = new ComboBox();
            combo.getItems().addAll(text1,text2);
    Javafx - ComboBox-combobox.png

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,256
    Rep Power
    19

    Default Re: Javafx - ComboBox

    Moved from New to Java, as was your last thread. Please take the effort to post in the correct section.

    And where's that SSCCE?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    ghansham is offline Member
    Join Date
    Jul 2013
    Location
    South America, Guyana
    Posts
    12
    Rep Power
    0

    Default Re: Javafx - ComboBox

    My apologies.

    Java FX Code:
    package comboboxselector;
    
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.layout.StackPane;
    import javafx.scene.text.Font;
    import javafx.scene.text.FontWeight;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    
    /**
     *
     * @author Ghansham
     */
    public class ComboBoxSelector extends Application {
        
        @Override
        public void start(Stage primaryStage) {
           
            Text text1 = new Text("Text 1");
            text1.setFont(Font.font ("Verdana",FontWeight.BOLD, 20));
            Text text2 = new Text("Text 2");
            text2.setFont(Font.font ("Verdana",FontWeight.BOLD, 20));
            
           
        
           ComboBox combo = new ComboBox();
           combo.getItems().addAll(text1,text2);
         
                
            StackPane root = new StackPane();
            
             root.getChildren().add(combo);
            
            Scene scene = new Scene(root, 300, 250);
            
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
         public static void main(String[] args) {
            launch(args);
        }
    }

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,256
    Rep Power
    19

    Default Re: Javafx - ComboBox

    Have you read the API for ComboBox? It specifically cautions against adding Nodes to the combo.

    The tutorial has an example of the correct way to set custom fonts by using a cell factory:
    Using JavaFX UI Controls: Combo Box | JavaFX 2 Tutorials and Documentation

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Javafx - Transitions
    By ghansham in forum JavaFX
    Replies: 19
    Last Post: 07-05-2013, 04:37 PM
  2. JavaFX Book | Learn JavaFX More In Depth
    By SnakeDoc in forum JavaFX
    Replies: 0
    Last Post: 05-17-2013, 11:10 PM
  3. Problem: Fill a comboBox from another combobox
    By Ridha in forum AWT / Swing
    Replies: 2
    Last Post: 03-08-2013, 02:34 PM
  4. Help with javaFX?!
    By JavaNoob!1 in forum JavaFX
    Replies: 7
    Last Post: 07-18-2012, 10:56 PM
  5. JavaFX Script and JavaFX Mobile
    By levent in forum Java Software
    Replies: 1
    Last Post: 01-27-2010, 04:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •