JavaFX Grid lines styling - css

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:-

Related

GridPane : Change grid line color

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.

QTableWidget grid doesn't fill the widget

I have created a simple QTableWidget, set StretchLastSection to true on the horizontal header, which works fine.
It however looks like this:
As you can see there is a little spacing after the last cell so the grid border doesn't line up with the header.
How do I fix this?

How do you affect line spacing in JavaFX hyperlinks?

I have a vbox, where I'm putting some hyperlinks.
Hyperlink clickableString;
clickableString = new Hyperlink();
clickableString.setStyle("-fx-text-fill: black;-fx-padding: 0; -fx-line-spacing: 0em;"); //set the hyperlink to black.
clickableString.setLineSpacing(0);
clickableString.setText("This is a test");
myVBox.getChildren().add(clickableString);
clickableString = new Hyperlink();
clickableString.setStyle("-fx-text-fill: black;-fx-padding: 0; -fx-line-spacing: 0em;"); //set the hyperlink to black.
clickableString.setLineSpacing(0);
clickableString.setText("This is a test");
myVBox.getChildren().add(clickableString);
I'm trying to get the spacing between the characters as small as possible, so that I can fit as many rows as possible. As it is, the space between the lines is about half a character tall. Does anyone know how to fine tune this?
Is it possible that the font itself is taking up the white space, and therefore, I can't remove the white space? Or is there some kind of padding that I can change?
Men,
I was looking into the same thing, but "-fx-line-spacing" does not appear in the official JavaFX CSS documentation.
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html
Edit -
But testing it worked. In my case I had to put a negative number to get the lines closer to each other.

Adding Shapes to GridPane results in wrong Position

I got the task to draw some points on a map. Wrote some code but currently every point I create via shapes will be added to the wrong position inside of my gridpane. Oh and I'm using JavaFX.
I added an imageView to the index 0,0 of my GridPane and every point is created through x and y position of the MouseEvent on the imageView.
After that I added the created point as a child of the GridPane and it's displayed at the center of the y-axis of the first grid.
Tried different things like anchorPanes and canvas but can't seem to get it working.
Code of my View:
http://pastebin.com/dCb7EN4d
Code of my Main:
http://pastebin.com/vp5tzxkG
I hope that's enough ^^'
pls help!
Greetings,
Ben
GridPane is a managed layout: it will position nodes that are added to it via the properties you set (using defaults if you don't set them). So when you add your circles to the grid pane, since you don't set any properties, it will place it in cell (0,0) and align it within that cell using default settings; i.e. it ignores the centerX and centerY properties.
What you should really do here is use a layout that does not manage the positioning of the nodes for you, such as a Pane (or possibly a Group). You can put the ImageView and the Circles in the pane, and then place the pane in the rest of your layout (in the scroll pane, I think).
The other option you have is to call setManaged(false) on the nodes you add to the GridPane in order to instruct the GridPane not to position them, though this feels like more of a workaround.

How to set the distance to the border in a GridPane?

I am unable to find a way to set the distance to the border in a GridPane. Now, the text starts immediately after the border stops, which is not very nice for the design. I could give all the children a padding, but I was thinking there must be a shorter way to do this (just some property of the GridPane).
Unfortunately, I was not able to find this anywhere online. I prefer a solution which uses FXML or CSS (preferably CSS), but if this must be done with some Java code, it is not a problem.
I have already tried:
Setting the margin of the GridPane in the CSS:
#someGridPane { -fx-border-insets: 5; }, but these insets are outside the border (and I want them inside).
Setting padding on all of the child elements, which is not as efficient as I had hoped).
So the question is: How to set the distance to the border in a GridPane?
Notes:
I am using JavaFX8
If the solution is somewhere online already, please let me know. (I searched for it for some time now)
Depending on what's in your grid pane you could cheat a bit.
GridPane > Text {-fx-translate-x : 5;}
GridPane > Label {-fx-label-padding: 0 0 0 5;}
Of course, add some style class names, but you get the idea.
There is a simpler, more natural solution:
GridPane {
-fx-padding: 5;
-fx-hgap: 5;
-fx-vgap: 5;
}
It does the same as using GridPane.setHgap(5) etc, but with CSS.

Resources