B4J Question CheckBox wrong style with designer

Saverio

Member
Licensed User
Longtime User
Hello everyone,

I having some problem with CheckBox added via designer
My B4J version is 4.7 on Windows 7 with jdk1.8.0_131

In short, if insert a CheckBox via designer, even disabled, the mark will show a bright black.
In the other hand, if added in code it will work as aspected.

It seems that the designer change the style or some sort.
Tried to reset the style (clear any style) and re-add the check-box style.
Got no luck

Someone knows something?
Thanks

CheckBox-Style.png
 

Attachments

  • CheckBox-Style.zip
    1.9 KB · Views: 233
Last edited:

Saverio

Member
Licensed User
Longtime User
Temporarily answering myself, but waiting for a better solution:

As a workaround I did several try.
The only one that seems work is to reload the main css file "modena.css"

It can be found inside the jar file under
"C:\Program Files\Java\jre1.8.0_131\lib\ext\jfxrt.jar
or under
C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar.

At least on my pc and in the above java version.

Open it with a decompressor (RAR, ZIP, ...) and under
"com\sun\javafx\scene\control\skin\modena\"
there is the file "modena.css". Copy it in the "Files" folder under the Application folder.
Now load it with the B4J ide in the files tab.

In the Application use the code:
B4X:
Dim  jo As JavaObject = MainForm.RootPane
jo.RunMethodJO("getScene",Null).RunMethodJO("getStylesheets",Null) _
  .RunMethod("add",Array(File.GetUri(File.DirAssets, "modena.css")))

or

B4X:
Dim jo As JavaObject = MainForm
jo.GetFieldJO("scene").RunMethodJO("getStylesheets",Null) _
  .RunMethod("add",Array(File.GetUri(File.DirAssets, "modena.css")))
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
It may be a Bug.

The stylesheets function is exposed in B4J

B4X:
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "modena.css")
 
Upvote 0

Saverio

Member
Licensed User
Longtime User
It may be a Bug.

The stylesheets function is exposed in B4J

B4X:
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "modena.css")

Sometimes one is concentrate on other things and don't see what stand in front of him.

Of course you are in the right ;) btw you loose an end parenthesis :rolleyes:

But the question remain. It is a bug?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I am pretty sure that yes.

I created a small example and this line throws false:

B4X:
    Log(checkbox2.Style = CheckBox1.Style)

And the difference are quite large.
 
Upvote 0

Saverio

Member
Licensed User
Longtime User
....To reply to myself, load "modena.css" isn't that so good workaround
because while it is good for CheckBoxes going wrong with other things.

Another workaround is create a file for example "CheckBox.css"
and load it with the code:

B4X:
  MainForm.Stylesheets.Add("/files/CheckBox.css")

and here the file content:

HTML:
.check-box:disabled {
    -fx-opacity: 0.5;
}

.check-box > .label:disabled {
    -fx-opacity: 0.5;
}

by now it seems work fine....
 
Upvote 0

Saverio

Member
Licensed User
Longtime User
It should be:
B4X:
MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Checkbox.css"))
From jFX.jar
HTML:
  public List getStylesheets(){
      return (List)AbsObjectWrapper.ConvertToWrapper(new List(), this.scene.getStylesheets());
    }

so it is exposed just a list with no manipulation

And from javafx documentation:
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/Scene.html#getStylesheets--
HTML:
  getStylesheets

  public final ObservableList<String> getStylesheets()

  Gets an observable list of string URLs linking to the stylesheets to use with this scene's
  contents.

  The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does
  not have a [scheme:]component, the URL is considered to be the [path] component only.
  Any leading '/' character of the [path] is ignored and the [path] is treated as a path
  relative to the root of the application's classpath.

     package com.example.javafx.app;

     import javafx.application.Application;
     import javafx.scene.Group;
     import javafx.scene.Scene;
     import javafx.stage.Stage;

     public class MyApp extends Application {

          @Override public void start(Stage stage) {
             Scene scene = new Scene(new Group());
             scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
             stage.setScene(scene);
             stage.show();
         }

         public static void main(String[] args) {
             launch(args);
         }
     }

  For additional information about using CSS with the scene graph, see the CSS Reference
  Guide.

  Returns:
  the list of stylesheets to use with this scene

if I have understood well, just provide the relative path.

Am I worng?
 
Upvote 0
Top