jhsheets / javafx-filterable-table-columns

24 stars 11 forks source link

Modular JavaFX does not export com.sun.javafx.css #5

Open cbm64chris opened 5 years ago

cbm64chris commented 5 years ago

In a modular JavaFX project, it is not possible to use this very useful project.

Caused by: java.lang.IllegalAccessError: class org.google.jhsheets.filtered.tablecolumn.editor.FilterMenuPopup (in module javafx.filterable.table.columns) cannot access class com.sun.javafx.css.StyleManager (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.css to module javafx.filterable.table.columns

AdoptOpenJDK 12 JavaFX 12

davidbio commented 5 years ago

@cbm64chris I just stumbled across the same problem and the problem seem to be 2 classes that import com.sun.javafx.css.StyleManager to apply css.

  1. I changed FilterMenuPopup.java from

    public class FilterMenuPopup extends PopupControl
    {
    static {
        StyleManager.getInstance().addUserAgentStylesheet(FilterMenuPopup.class.getResource(FilterMenuPopup.class.getSimpleName() + ".css").toString());
    }
    
    public FilterMenuPopup(String title) 
    {
    }
    }

    to

    public class FilterMenuPopup extends PopupControl
    {
    public FilterMenuPopup(String title) 
    {
        ((Parent) getStyleableNode()).getStylesheets()
                .add(FilterMenuPopup.class.getResource(FilterMenuPopup.class.getSimpleName() + ".css").toString());
    }
    }
  2. Also, I changed FilterMenuButton .java from

    public class FilterMenuButton extends Button
    {
    static {
    StyleManager.getInstance().addUserAgentStylesheet(FilterMenuButton.class.getResource(FilterMenuButton.class.getSimpleName() + ".css").toString());
    }
    
    public FilterMenuButton(final FilterMenuPopup popup)
    {
    }
    }

    to

    public class FilterMenuButton extends Button
    {
    public FilterMenuButton(final FilterMenuPopup popup)
    {
        getStylesheets().add(FilterMenuButton.class.getResource(FilterMenuButton.class.getSimpleName() + ".css").toString());
    }
    }

    It works for me, comes without warranty. 😃