JavaFX LineChart legend style
By : Juanita Solis
Date : March 29 2020, 07:55 AM
hope this fix your issue I ran into this issue as well. Came up with a work-around that detects when the legend items are created so that dynamic styling can be added to them. I added a ListChangeListener to the legend's "getChildrenUnmodifiable()" ObservableList, which in turn adds a ListChangeListener to each of the legend's children as they get added. From within this listener, we can tell when new items are being added to the legend (or removed). This allow us to then make the dynamic style changes. code :
for (Node n : lineChart.getChildrenUnmodifiable())
{
if (n instanceof Legend)
{
final Legend legend = (Legend) n;
// remove the legend
legend.getChildrenUnmodifiable().addListener(new ListChangeListener<Object>()
{
@Override
public void onChanged(Change<?> arg0)
{
for (Node node : legend.getChildrenUnmodifiable())
{
if (node instanceof Label)
{
final Label label = (Label) node;
label.getChildrenUnmodifiable().addListener(new ListChangeListener<Object>()
{
@Override
public void onChanged(Change<?> arg0)
{
//make style changes here
}
});
}
}
}
});
}
}
|
How to avoid child elements to get text-decoration style from body element's style
By : user2396172
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further HTML example: , You can get rid of text-decoration set on an ancestor using code :
display: inline-block;
width: 100%;
|
Element style not allowed as child of element body in this context (<style scoped> not validating)
By : Ereny Rona
Date : March 29 2020, 07:55 AM
wish of those help The W3C Markup Validator, when acting as an HTML5 checker, handles this issue according to various drafts such as HTML 5.1 Nightly, which right now says that the style element may appear only inside the head element, except when the scoped attribute is present, in which case it may appear “where flow content is expected, but before any other flow content other than inter-element whitespace and style elements, and not as the child of an element whose content model is transparent”. In your actual example, the element appears after a script element (which is counted as flow content). Changing the order of the elements thus changes the syntax to valid, under the given definition. Alternatively, you can just wrap the style element in a div element: code :
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<script type="text/javascript"></script>
<div>
<style scoped></style>
</div>
</body>
</html>
|
Apply style on hover of an element to another element only if this other element is a child of the hovered element?
By : Haibin Xie
Date : March 29 2020, 07:55 AM
it should still fix some issue I have some divs that contain images. When hovered over the divs, the images should rotate in order to create an album like effect. , Update your CSS to code :
#main div:hover img {
/* styles here */
}
|
Can I include a JavaFX LineChart in a JavaFX GUI
By : TP TORA
Date : March 29 2020, 07:55 AM
I hope this helps . As @James_D said you simply need another container to achieve that. A Pane can contain GUI controls as well as another Pane. In the example below I put a GridPane with few buttons inside a BorderPane that divides the window into right and left part. code :
@Override
public void start(Stage stage) {
stage.setTitle("A Title");
// Root element
BorderPane root = new BorderPane();
// GridPane
GridPane grid = new GridPane();
grid.setPadding(new Insets(10,10,10,10));
grid.setVgap(10);
grid.add(new Button("Button 1"), 0, 0);
grid.add(new Button("Button 2"), 0, 1);
grid.add(new Button("Button 3"), 0, 2);
// Chart
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
final LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis);
XYChart.Series series = new XYChart.Series();
series.setName("Chart");
series.getData().add(new XYChart.Data(1, 5));
series.getData().add(new XYChart.Data(2, 10));
lineChart.getData().add(series);
root.setLeft(grid);
root.setRight(lineChart);
Scene scene = new Scene(root, 600, 300);
stage.setScene(scene);
stage.show();
}
|