So, cutting my teeth on JavaFX, so far things are moving along fine.
However, all of the text fields have a line running across them, 10px or so from the top.
Not just in my application, but in the SceneBuilder application as well.
Note, I'm not using any explicit CSS, I don't know what SceneBuilder uses. The screen shot is from SceneBuilder, my screens look identical.
So, it's 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 curious if anyone else has seen this and has a suggestion.
Edit: I downloaded the samples, it's clearly something to do with the Modena theme. The Caspian theme looks just fine. Below is a screenshot from the Modena.jar TextFields section. It's interesting that the TextArea
suffers a similar issue, though not as universally as the TextField
.
More addenda:
Folks keep clamoring for this, so here it is. I essentially just followed this: https://docs.oracle.com/javafx/2/get_started/form.htm and use a default Netbeans 8.0.2 JavaFX Application project. Just cut and pasted it in from the website.
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); } }
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's is a screen shot of the ThreeDOM view from ScenicView 8.6, notice 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 the sample screen using the Caspian theme via:
System.setProperty("javafx.userAgentStylesheetUrl", "caspian");
TextField class is a part of JavaFX package. It is a component that allows the user to enter a line of unformatted text, it does not allow multi-line input it only allows the user to enter a single line of text. The text can then be used as per requirement.
A Text is a geometric shape (like a Rectangle or a Circle), while Label is a UI control (like a Button or a CheckBox). In Swing, geometric shapes were restricted to the painting mechanism, while in JavaFX they can be used in more generic ways. And you can use a Text clipping, giving the node shape by the text.
The JavaFX Stage class is the top level JavaFX container. The primary Stage is constructed by the platform. Additional Stage objects may be constructed by the application. Stage objects must be constructed and modified on the JavaFX Application Thread.
This is a known unresolved bug.
The problem seems to be that it isn't reproducible for the developers.
In the comments of the bug report the use of a jvm parameter is suggested:
-Dprism.disableRegionCaching=true
However, if anyone is able to reproduce this very rare bug, my suggestion is to:
Emm... I am not 100% sure cause I don't have the effect on my jvm though I have Linux platform; But still I tried to emulate (? not sure I succeeded pretty well) anyways I guess the issue you describe may be really related to
The code you represented I modified a bit to show what happens to gridpanel lines if components located 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 running app looks like that :
Image A :
...so the black line appears in text field in distance about 10px maybe just because the Vgap set to 10; Moreover, see the "welcome" text is crossed but with vertical lines; I tested if "not to use font" for scenetitle it located correctly (see image);
Image B
So something is maybe wrong with GridPane I guess; Maybe the default GridPane has "lines visible" or something but after components added the lines "disposed" but because of TextField which should contain "text" with "font" (see image A vertical lines cross text because of the font) the repaint doesn't work properly and you can see the black line at the top as image A shows; I cannot emulate the effect totally but still I may suggest where the "un-disposed" line may come from or something :)
I'll try to analyse a bit further anyways the info I describe in this answer may help you to find where to start debugging;
If you need some additional information please let me know;
Good luck :)
toolkit I used to test :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With