2 Replies Latest reply: Apr 13, 2012 9:27 AM by 927955 RSS

    TextField on JFXPanel - not seeing the typed in characters

    927955
      I am learning FXControls by using a Swing app and a JFrame and place a JFXPanel on it.
      So far I have placed a slider and a label and was able to bind the label to the value of the slider as it is moved - very Nice.

      When I placed a TextField on the JFXPanel it does get placed and displays the prompt text as expected.
      When I click on the TextField control, the focus is given but any text I type in are not displayed.

      Using the debugger (Eclipse in this case) I see that the content of the TextField shows the entered text in a sort of push down stack like order.
      So what do I need to get the text to display as I type.

      I have not added any listener to the TextField as of yet. Is this required just to get to see the entered text as displayed?

      Using 2.0
        • 1. Re: TextField on JFXPanel - not seeing the typed in characters
          Narayan
          Hi Venture,

          It runs fine on my computer with below codes. I dont' know why it's not running in your computer. May be you are using older version of javafx
          My spec:
          Core i5 , Windows 7 (64-bit) with java 1.7.0 (32bit) and javafx 2.0.2 (32bit)
          public class JavaSwingTest extends JFrame{     
               public void buildGUI(){
                    final JFXPanel panel = new JFXPanel();          
                    Platform.runLater(new Runnable() {
                           public void run() {
                                HBox box = new HBox();
                            Scene sc= new Scene(box);
                            TextField field = new TextField();
                            field.setPromptText("this is prompt");
                            box.getChildren().add(field);          
                            panel.setScene(sc);
          
                           }
                       });                    
                    getContentPane().add(panel);          
                    setVisible(true);
                    setSize(200,200);          
                    
               }
               
               public static void main(String[] args){
                    JavaSwingTest t = new JavaSwingTest();
                    t.buildGUI();
               }
          }
          Thanks
          Narayan
          • 2. Re: TextField on JFXPanel - not seeing the typed in characters
            927955
            I found the cause of my issue:
            I had bound the textProperty of the Textfield to a local textProperty variable. I had not set the value of the local textProperty variable to anything. When I changed to set the textProperty of the bound variable to an empty string then it worked properly and showed the prompt string. If I omitted the binding then it worked properly. If I set the textProperty of the bound variable to some non-empty string then it also works but does not show the prompt (to be expected).

            I had assumed that there was no need to set a string into the textProperty of the bound variable (I guess null is considered different to an empty string).