B4J Question How do I translate a RootPane inline style into a CSS file

Cableguy

Expert
Licensed User
Longtime User
hi, I have this code line that works:

MainForm.RootPane.Style = "-fx-background-color:#e8f5fc;"

but since I am styling several nodes, I wanted to pass this code line to a CSS file, where I already have some styles, but I can't get it right;

I have tried:

.root

.rootpane

.root .pane

Nothing seems to do the trick!

Please Help!
 

Cableguy

Expert
Licensed User
Longtime User
where I already have some styles,
My problem is not the implementation of a CSS file in my project, but just how the rootpane is to be identified within it.[/quote]
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I may be wrong but isn't the rootpane an anchorpane so maybe .anchorpane or something like it may work.
I was, according to Oracle
Styling the Anchor Pane
Anchor panes do not have any additional properties beyond the basic set of properties for all layout panes.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I am!!! I have styled a Menubar without any problems, as the identifiers are easily found googling around, not the rootpane.
The only inline style that I still have laying around in my code is just this one, and I want to pass it to my css file, which is already added to my form!
Even the B4J documentation has no reference on the identifiers to include in a css file for known views.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Basically the same as above.

B4X:
Dim jo As JavaObject = MainForm.RootPane
MainForm.RootPane.Id = "root-pane"    ' do this before loading css file
Pane1.Id = "pane1-pane"
jo.RunMethodJO("getStylesheets",Null).RunMethod("add",Array("files/mycss.css"))
....

'
' mycss.css file
'#root-pane {
' -fx-background-color: #8fbc8f;
'}
'#pane1-pane {
' -fx-background-color: red;
'}
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
as far as I'm aware, using # means setting the views ID, which I want to avoid, just because that would target that particular view, and not the type of view,
but its a start.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
if you want all the panes to use the same css just use .pane (that includes the rootpane)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I did, din't work, can it be .anchorpane ?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
try anchorpane no dot
ie
B4X:
AnchorPane {
    -fx-background-color: red;
}
oops, it appears to be case sensitive so AnchorPane not anchorpane.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I just can't get that to work...!!
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Most odd - its working here.
java1.8.0_60 and latest b4j with designer.
 

Attachments

  • rootpane css.zip
    1.8 KB · Views: 237
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I have the same Java version
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
In my code I use:

MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Main.css"))


in yours you use:

Dim jo As JavaObject = MainForm.RootPane

jo.RunMethodJO("getStylesheets",Null).RunMethod("add",Array("files/mycss.css"))


why? aren't those the same?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Are you running in release mode?, as I cannot get it to work in release, yet in debug it works fine.

now it works in release mode using:
B4X:
jo.RunMethodJO("getStylesheets",Null).RunMethod("add",Array(File.GetUri(File.DirAssets, "mycss.css")))
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
it worked in your example, but not in mine... using the JavaObject method didn't help.
there is something fishy going on with this css, both your approach with JavaObject, as well as mine with the stylesheets attribule, do style the menubar, but not the root pane.
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Think that's a question for Erel, cos I have no idea lol
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Anyway, Thanks for trying to help me
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I have taken your example as a Base and added the missing pieces from my project, and removed the extra Pane you had there, and now it all Works!!
 
Upvote 0
Top