GridPane : Change grid line color - javafx

How can i change the grid lines color / can i change the grid lines color?
Cant seem to find a css solution.

You can use this css it work for me :
.mygridStyle Line {
-fx-stroke : red;
}
then you attach the css class with the scene builder or with myGrid.getStyleClass().add("mygridStyle");

As stated
in this question here
you shouldn't use GridPane to paint grid lines, you need to put content inside the cells, and then specify content borders. The visible grid line property if for debugging only, see doc.

Related

How to remove the rounded corners from JavaFX buttons

I've noticed that buttons in JavaFX have rounded corners, which means when you have a grid of them there are little white spaces visible between.
This illustrates the problem
I'd like to make my buttons appear as rectangles, with right angled corners, is this possible? I assume this might be possible with CSS, but I can't find this question being asked before.
Thanks.
You can do Via CSS :
"-fx-background-radius: 0"
You can add your CSS file in several ways by code , by Inline , External file
By Code :
Button rectangleButton = new Button();
roundButton.setStyle("-fx-background-radius: 0");
By FXML Inline :
By FXML External :
mystyle.css file
.button{
-fx-background-radius: 0;
}
then choose directory of file to apply the style to your container

QT Tab bar's top highlight with stylesheet

I have a problem when trying to change the color of QTabBar's top line (blue line in the picture below).
Is this a separate part of tabBar (like scroller or tear) or its top border ? And how can I change its color with styleSheet and leave the other parts of tabBar unchanged?
P.S. : My tabBar::styleSheet returns an empty string, so I can't get current style and make changes in it.
If you're using a "system" style, you may not be able to change the color of the line (cause representation of UI elements is not handled by Qt but by the system).
You should define a complete style for QTabBar (and maybe QTabWidget too) that you can customize as you wish.
See the Qt Style Sheets Examples page.
Problem solved:
setStyleSheet("QTabBar::tab:selected { selection-background-color: red; }");

JavaFX Grid lines styling

Is there a way to style the grid lines of a gridpane in JavaFx? I could only see the option to make it visible or hidden.
-fx-grid-lines-visible: true;
Even if we can set a background for each cell that would fill the entire cell just like in the following diagram, that would be great.
Is there really an option to do this either by CSS or by Java coding?
I added hgap and vgap to achieve this.
-fx-vgap: 10;
-fx-hgap: 10;
But it looks like this:-
I need to remove the intersecting lines as circled above. The required one would be like this:-

javaFX width css not reacting?

Im trying to get a dynamic scrollpane in my JavaFX (FXML) application using CSS. my CSS for the scrollpane looks like this:
.scroll-pane {
-fx-width: 80%;
-fx-height: 80%;
-fx-background-color: #FF3333;
}
the color works, but the size properties don't if I open the CSS in JavaFX scene builder it doesn't show the height and width lines at all.
I assume im missing something pretty basic, but I can't seem to figure it out.
As far as I know you cant use -fx-width/-fx-height at all and you cant use percentage values for it. The width and height of elements are read-only. You can set -fx-pref-width, -fx-pref-height, -fx-max-width, -fx-min-width, -fx-max-height and -fx-min-height to adjust the size of Java FX elements.
Check the CSS Reference Documentation out to see which CSS styles are possible.
If you want to have the size as percentage you probably need to bind the size to another property.
As example:
myView.prefWidthProperty().bind(myOtherView.widthProperty().multiply(0.75));
There is another post about percentage values with the use of a GridLayout.
How do specify a width percentage in JavaFX 2 using FXML?

Flex scrollbar styling issue

I'm trying to style vscrollbar and hscrollbar inside a Vbox.But there's always a white square thing at the right bottom cornor which can not be styled.
My CSS is:
ScrollBar{
downArrowUpSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
downArrowOverSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
downArrowDownSkin: Embed(source="assets/images/scrollbar/arrow_down.png");
upArrowUpSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
upArrowOverSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
upArrowDownSkin: Embed(source="assets/images/scrollbar/arrow_up.png");
thumbDownSkin: Embed(source="assets/images/scrollbar/thumb.png");
thumbUpSkin: Embed(source="assets/images/scrollbar/thumb.png");
thumbOverSkin: Embed(source="assets/images/scrollbar/thumb.png");
trackSkin:Embed(source="assets/images/scrollbar/track.png");
fillAlphas:0,0,0,0;}
Could anyone help me out?Much Thanks!
This is a weird one. The white box at the bottom right is actually a (raw) child of the container.
To get around this you need to subclass whatever container you want to add your styled scrollbars to and remove the child called "whitebox":
var whitebox:DisplayObject = rawChildren.getChildByName('whiteBox');
if (whitebox)
rawChildren.removeChild(whitebox);
IIRC you need to do the above in two places: an override of createChildren and an override of validateDisplayList. In both cases remember to call the super class method first!
That area isn't controlled by the scroll bar(s), it's part of the original container. Does the VBox have it's background colour set to black?

Resources