All my JavaFX text fields have lines in them

So, I cut my teeth in JavaFX, so far so good.

However, all text fields have a line passing through them, 10 pixels or so on top.

Not only in my application, but also in the SceneBuilder application.

Note that I do not use explicit CSS, I do not know what SceneBuilder uses. Screen shot from SceneBuilder, my screens look the same.

JavaFX TextFields

So this is something fundamental.

java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) 

On Mac OS 10.9.5

Just wondering if anyone else has seen this and has a suggestion.

Edit: I downloaded the samples, this is clearly something related to the Modena theme. The Caspian theme looks just fine. Below is a screenshot from the Modene.jar TextFields section. Interestingly, TextArea experiencing a similar problem, although not as universally as TextField .

Modena.jar screenshot

Additional additions:

People keep pushing for it, so here it is. I essentially just stuck to this: https://docs.oracle.com/javafx/2/get_started/form.htm and used the default NetBeans 8.0.2 JavaFX application project. Just cut and paste it from the site.

 public class Fxlinetest extends Application { @Override public void start(Stage primaryStage) { primaryStage.setTitle("JavaFX Welcome"); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text("Welcome"); scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle, 0, 0, 2, 1); Label userName = new Label("User Name:"); grid.add(userName, 0, 1); TextField userTextField = new TextField(); grid.add(userTextField, 1, 1); Label pw = new Label("Password:"); grid.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); grid.add(pwBox, 1, 2); Button btn = new Button("Sign in"); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); grid.add(hbBtn, 1, 4); final Text actiontarget = new Text(); grid.add(actiontarget, 1, 6); Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } 

Example screenshot of a form

 java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode) 

Here is a screenshot from ThreeDOM view from ScenicView 8.6, pay attention to the line: Viewing from three points of view from ScenicView - pay attention to the line

 java version "1.8.0_74" Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode) 

Here's a sample screen using a Caspian theme through:

  System.setProperty("javafx.userAgentStylesheetUrl", "caspian"); 

Caspian theme view

+71
java javafx textbox
Jun 07 '15 at 20:44
source share
2 answers

This is a known unresolved error .

The problem is that it is not playable by developers.

The error report comments suggest using the jvm parameter:

 -Dprism.disableRegionCaching=true 

However, if someone can reproduce this very rare mistake, my suggestion is:

  • Modify the modena css file until the error is resolved and this information is shared. this may help, as Caspian seems to work.
  • debug javafx source if necessary to isolate the problem. however the problem may be deeper but worth doing
+6
Feb 19 '16 at 5:46
source share

Umm ... I'm not 100% sure because I do not affect my jvm, although I have a Linux platform; But still, I tried to imitate ("I'm not sure that I succeeded very well), anyway, I think that the problem you are describing can really be related to

  • a) font
  • b) redraw the problem

The code you presented changed me a bit to show what happens to the mesh lines if the components are in “some” order;

 import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class BlackLineIssueJavaFXApplication1 extends Application { @Override public void start(Stage primaryStage) { System.setProperty("javafx.userAgentStylesheetUrl", "Modena"); //Modena,caspian primaryStage.setTitle("JavaFX Welcome"); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); // grid.setGridLinesVisible(false);//<--- Text scenetitle = new Text("Welcome");//original // Label scenetitle = new Label("Welcome");//modified scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));//original // scenetitle.setFont(Font.font("Verdana", FontWeight.LIGHT, 30));//modified grid.add(scenetitle, 0, 0, 2, 1);//original // grid.add(scenetitle, 0, 0);//modified Label userName = new Label("User Name:");//original // Text userName = new Text("User Name:"); // userName.setFont(Font.font("Tahoma", FontWeight.NORMAL, 11)); // grid.add(userName, 0, 1);//original grid.add(userName, 0, 1,1,2);//modified grid.setGridLinesVisible(true);//<--- TextField userTextField = new TextField(); // userTextField.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));//modified userTextField.setOpacity(0.5);//<---- // grid.add(userTextField, 1, 1);//original grid.add(userTextField, 1, 1,1,2);//modified grid.setGridLinesVisible(false);//<--- Button btn = new Button("Sign in"); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); grid.add(hbBtn, 1, 4);//original //grid.add(hbBtn, 1, 3);//modified final Text actiontarget = new Text(); grid.add(actiontarget, 1, 6); Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); primaryStage.show(); } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } } 

The launch of the application is as follows:

Image A:

enter image description here

... therefore a black line appears in the text field at a distance of about 10 pixels, perhaps only because Vgap is set to 10; Moreover, see the text of the "greeting" crossed, but with vertical lines; I tested if "do not use a font" for a scenetitle , it is correctly located (see. Image);

Image B

enter image description here

So maybe something is wrong with the GridPane. Maybe by default the GridPane has “visible lines” or something, but after the components have added “disposed” lines, but because of the TextField, which should contain “text” with a “font” (see Image. Vertical the lines cross the text due to the font), repaint doesn't work correctly, and you can see the black line at the top, as image A shows; I can not fully emulate the effect, but still I can offer where a “loose” line or something like that can occur.

I will try to analyze a little further, since the information that I describe in this answer can help you find where to start debugging;

If you need more information, please let me know;

Good luck :)

Tool

which I used for testing:

  • JDK 1.0.8_25-
  • jre-1.8.0_60 (Linux x64)
  • ide: netbeans 8.0.1
+1
Feb 17 '16 at 7:07
source share



All Articles