Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-fx-border-style doesn't look as expected on runtime but on SceneBuilder

Tags:

css

javafx

fxml

The following style looks as expected on SceneBuilder. (The only visible border is the bottom one and it is dotted.)

But it looks different on runtime. (All borders are visible and solid.)

.floatingPanel-title{
  -fx-text-alignment: center;
  -fx-text-fill: CORNFLOWERBLUE;
  -fx-font-weight: bold;
  -fx-font-size: 15px;
  -fx-background-color: #545050;
  -fx-border-style: none none dotted none;
  -fx-border-color: white;
}

I tried some by swaping the lines or commenting-out some parts but the problem is still an issue.

What do you suggest as a solution?

Note:

1) I applied this style to a label and also a panel. The problem is valid for both.

2) I have already tried clean-compile. Problem still exists.

like image 786
bAris Avatar asked Mar 17 '23 06:03

bAris


1 Answers

It seems to be a bug, sorry. On my testing with JavaFX 8u40:

1) Even though the official JavaFX CSS Reference Guide says on -fx-border-style as

A series of border style values, separated by commas. Each item in the series applies to the corresponding item in the series of border colors.

The comma separated example behaves weird and wrongly than not comma separated one. i.e. these

  -fx-border-style: dotted  dashed  dashed  dashed;
  -fx-border-color: red red red red;
  -fx-border-width: 2;

and

  -fx-border-style: dotted , dashed  , dashed  , dashed;
  -fx-border-color: red red red red;
  -fx-border-width: 2;

renders differently. Not using commas seems more accurate despite the doc.

2) The border style option none is not working in JavaFX 8 but in JavaFX 2. Instead of this you may choose to use hidden.

-fx-border-style: hidden hidden dotted hidden;

3) The different rendering of SceneBuilder and at runtime may be caused by usage of different versions of JavaFX. You can inspect the used version by

System.out.println(com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());

Finally, after observation of yourself, you are welcome to file a jira issue or vote for existing one.

like image 51
Uluk Biy Avatar answered Apr 05 '23 22:04

Uluk Biy