-2

The echo of passwordfield is displayed properly in the scene builder.

enter image description here

enter image description here

I also tried using netBeans, and the result is the same.

This is coding environment :

Jdk: 1.8.0.191
intelliJ:2019.1
netBeans: 8.0

Main.java :

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("test.fxml"));
        primaryStage.setTitle("test");
        primaryStage.setScene(new Scene(root)); 
        primaryStage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }

}

test.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <PasswordField layoutX="237.0" layoutY="179.0" promptText="password" />
   </children>
</AnchorPane>

hope it show default echo.

Pagbo
  • 691
  • 5
  • 13
null null
  • 1
  • 2
  • I also tried to set the file coding in utf-8,but it didnt work. – null null May 29 '19 at 09:12
  • Maybe a duplicated question [Encode String to UTF-8](https://stackoverflow.com/questions/5729806/encode-string-to-utf-8) – Shim-Sao May 29 '19 at 09:17
  • I would try the textfield if i cant fix this garbled bug.sorry I am a newcomer didnt know how to edit the problem to make it better even i know what i actually want to ask.Besides,i m bad at English. – null null May 29 '19 at 09:44
  • Indeed, it looks like to an encoding problem (have a look on the workspace encoding maybe). At least this is not the only problem you get, it seems you use the JavaFX 11 with scenebuilder (like the namespace suggests is : `xmlns="http://javafx.com/javafx/11.0.1"` with a Java 8 program from what you said, you should harmonize the versions (8 for both or 11 for both). – Pagbo May 29 '19 at 09:47
  • 1
    This can solve your issue: [JavaFX PasswordField echo char different on Different computer ](https://stackoverflow.com/questions/53368664/javafx-passwordfield-echo-char-different-on-different-computer) – Shim-Sao May 29 '19 at 09:54
  • i already saw it before,but still not work. maybe i should change to use swing. – null null May 29 '19 at 10:20
  • Did you bother running `chcp` from the command line? If you read the previous question, why would you leave that info out? – SedJ601 May 29 '19 at 14:09

1 Answers1

0

I finally get the solution!!!!!! Just make sure to write the code under jdk11, and it has little to do with file encoding. setup jdk11 and setup a JavaFX Project for JDK 11 Using Intellij.

bug

no bug

null null
  • 1
  • 2