JFXtras / jfxtras-styles

Java, JavaFX themes or look and feels. Currently contains JMetro theme.
https://pixelduke.com/java-javafx-theme-jmetro/
642 stars 144 forks source link

TreeView - Empty rows show pressed background when pressed #198

Closed Exopandora closed 3 years ago

Exopandora commented 3 years ago

Issue: If you click on empty rows in a TreeView it will display the pressed background color for the respective row.

The following TreeView only contains one TreeItem named "root" with one child named "child":

grafik

This issues might be somewhat related to #47

Test code: TestTreeView .java

import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;
import jfxtras.styles.jmetro.JMetro;
import jfxtras.styles.jmetro.Style;

public class TestTreeView extends Application {
    @FXML
    private TreeView<String> treeview;

    public void initialize() {
        TreeItem<String> root = new TreeItem<String>("root");
        TreeItem<String> child = new TreeItem<String>("child");
        root.getChildren().add(child);
        root.getChildren().get(0).getValue();
        this.treeview.setRoot(root);
    }

    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader = new FXMLLoader(this.getClass().getResource("TestTreeView.fxml"));
        loader.setController(this);
        Parent root = loader.load();
        Scene scene = new Scene(root);
        JMetro jMetro = new JMetro(Style.LIGHT);
        jMetro.setScene(scene);
        stage.setScene(scene);
        stage.show();
    }

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

TestTreeView.fxml

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.TreeView?>
<TreeView fx:id="treeview" prefHeight="200.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" />
dukke commented 3 years ago

Good catch!

Exopandora commented 3 years ago

Thanks!