Stack Overflow Asked on December 7, 2021
When i’m creating TextField in my App then in it then there are places where appears blur.
Example: 1.There is a blur at the beginning of input :
Then the blur appears again, and this happens throughout the field.
I don’t understand why this is happens and hox fix it
Code of fragment if this need:
private void inputSaveName() {
Stage nameStage = new Stage();
nameStage.initModality(Modality.WINDOW_MODAL);
nameStage.initOwner(saveStage);
nameStage.initStyle(StageStyle.UNDECORATED);
nameStage.initStyle(StageStyle.TRANSPARENT);
BorderPane saveBorder = new BorderPane();
saveBorder.setStyle("-fx-background-color:saddlebrown;" +"-fx-border-width:5;" + "-fx-border-radius:16;" + "-fx-font-family: Cambria;" + "-fx-border-color:olive");
Scene nameScene = new Scene (saveBorder,300,120);
nameScene.setFill(Color.TRANSPARENT);
Rectangle rect = new Rectangle(300,120);
rect.setArcHeight(40.0);
rect.setArcWidth(40.0);
saveBorder.setClip(rect);
Button acceptNameButton = new Button("Accept");
Button cancelNameButton = new Button("Cancel");
acceptNameButton.setStyle("-fx-background-color: darkkhaki;" + "-fx-background-insets: 0 2 2 0;" + "-fx-padding: 8;" + "-fx-font-size:15;" + "-fx-text-alignment:
center");
cancelNameButton.setStyle("-fx-background-color: darkkhaki;" + "-fx-background-insets: 0 0 2 2;" + "-fx-padding: 8;" + "-fx-font-size:15;" + "-fx-text-alignment:
center");
cancelNameButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent ae) {
nameStage.close();
}
});
TextField nameField = new TextField();
nameField.setPromptText("Write save name");
nameField.setFont(new Font(18));
HBox buttonBox = new HBox();
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setHgrow(acceptNameButton, Priority.ALWAYS);
buttonBox.setHgrow(cancelNameButton, Priority.ALWAYS);
acceptNameButton.setMaxWidth(130);
cancelNameButton.setMaxWidth(130);
buttonBox.getChildren().addAll(acceptNameButton,cancelNameButton);
saveBorder.setBottom(buttonBox);
saveBorder.setCenter(nameField);
nameStage.setScene(nameScene);
nameStage.show();
}
i just try ur code locally :
public class test2 extends Application {
@Override
public void start(Stage stage) throws Exception {
Stage nameStage = new Stage();
nameStage.initModality(Modality.WINDOW_MODAL);
// nameStage.initOwner(saveStage);
nameStage.initStyle(StageStyle.UNDECORATED);
nameStage.initStyle(StageStyle.TRANSPARENT);
BorderPane saveBorder = new BorderPane();
saveBorder.setStyle("-fx-background-color:saddlebrown;" + "-fx-border-width:5;" + "-fx-border-radius:16;" + "-fx-font-family: Cambria;" + "-fx-border-color:olive");
Scene nameScene = new Scene(saveBorder, 300, 120);
nameScene.setFill(Color.TRANSPARENT);
Rectangle rect = new Rectangle(300, 120);
rect.setArcHeight(40.0);
rect.setArcWidth(40.0);
saveBorder.setClip(rect);
Button acceptNameButton = new Button("Accept");
Button cancelNameButton = new Button("Cancel");
acceptNameButton.setStyle("-fx-background-color: darkkhaki;" +
"-fx-background-insets: 0 2 2 0;" + "-fx-padding: 8;" + "-fx-font-size:15;" +
"-fx-text-alignment: center");
cancelNameButton.setStyle("-fx-background-color: darkkhaki;" +
"-fx-background-insets: 0 0 2 2;" + "-fx-padding: 8;" +
"-fx-font-size:15;" + "-fx-text-alignment: center");
cancelNameButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent ae) {
nameStage.close();
}
});
TextField nameField = new TextField();
nameField.setPromptText("Write save name");
nameField.setFont(new Font(18));
HBox buttonBox = new HBox();
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setHgrow(acceptNameButton, Priority.ALWAYS);
buttonBox.setHgrow(cancelNameButton, Priority.ALWAYS);
acceptNameButton.setMaxWidth(130);
cancelNameButton.setMaxWidth(130);
buttonBox.getChildren().addAll(acceptNameButton, cancelNameButton);
saveBorder.setBottom(buttonBox);
saveBorder.setCenter(nameField);
nameStage.setScene(nameScene);
nameStage.show();
}
public static void main(String[] args) {
launch(args); }
}
nothing wrong with this code, and no artifact on my screen
maybe something wrong with ur gpu, or ur javafx i am using jdk 14.0.1, javafx 14 with gradle, maybe u need move on to the latest version :)
Answered by h4ckm3-ID on December 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP