Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException using modular approach #142

Open
wunmiji opened this issue Jul 15, 2021 · 3 comments
Open

NullPointerException using modular approach #142

wunmiji opened this issue Jul 15, 2021 · 3 comments

Comments

@wunmiji
Copy link

wunmiji commented Jul 15, 2021

Saw this error when using ikonli-icons with modular approach in a simple javafx application.

modular.info

module com.example {

    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.graphics;
    requires javafx.web;
    requires org.kordamp.iconli.core;
    requires org.kordamp.ikonli.javafx;
    requires org.kordamp.ikonli.entypo;

    opens com.example.controller.login to javafx.fxml;
    exports com.example.controller.login;
}

pom.xml

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>11</maven.compiler.release>
        <javafx.version>11.0.1</javafx.version>
        <javafx.maven.plugin.version>0.0.4</javafx.maven.plugin.version>
        <ikonli.version>11.0.0</ikonli.version>
        <mainClass>com.example.controller.login.Launcher</mainClass>
    </properties>

    <!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-core -->
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-core</artifactId>
            <version>${ikonli.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-javafx -->
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-javafx</artifactId>
            <version>${ikonli.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.kordamp.ikonli/ikonli-entypo-pack -->
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-entypo-pack</artifactId>
            <version>${ikonli.version}</version>
        </dependency>

example.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import org.kordamp.ikonli.javafx.FontIcon?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button contentDisplay="GRAPHIC_ONLY" layoutX="214.0" layoutY="159.0" mnemonicParsing="false" prefHeight="117.0"  prefWidth="173.0">
         <graphic>
            <FontIcon iconLiteral="enty-beamed-note" iconSize="70" />
         </graphic>
      </Button>
   </children>
</AnchorPane>

Console output

[INFO] 
[INFO] --- javafx-maven-plugin:0.0.4:run (default-cli) @ Example ---
java.lang.NullPointerException
	at javafx.graphics/com.sun.javafx.font.directwrite.DWGlyph.createBitmap(DWGlyph.java:287)
	at javafx.graphics/com.sun.javafx.font.directwrite.DWGlyph.getCachedBitmap(DWGlyph.java:273)
	at javafx.graphics/com.sun.javafx.font.directwrite.DWGlyph.getD2DMask(DWGlyph.java:167)
	at javafx.graphics/com.sun.javafx.font.directwrite.DWGlyph.getPixelData(DWGlyph.java:352)
	at javafx.graphics/com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:258)
	at javafx.graphics/com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148)
	at javafx.graphics/com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101)
	at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
	at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
	at javafx.graphics/com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
	at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
	at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
	at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
	at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
	at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
	at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
	at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
	at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
	at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
	at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
	at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
	at javafx.graphics/com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at javafx.graphics/com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
	at java.base/java.lang.Thread.run(Thread.java:829)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
@aalmiray
Copy link
Collaborator

Please update to latest Ikonli version 12.2.0 and try again. Note that the module names were updated in version 12.0.0 -> #59

@wunmiji
Copy link
Author

wunmiji commented Jul 16, 2021

Have done it...but the error is only for modular and not non-modular
Here is quick and simple example https://github.com/wunmiji/Ikonli-icons-12.2.0-modular-exmaple

Please preview sir if am not doing the right thing in modular

@aalmiray
Copy link
Collaborator

@wunmiji I cloned https://github.com/wunmiji/Ikonli-icons-12.2.0-modular-exmaple (at commit 4858a65c003073662b36eaeff5b23d81e66408a6) and can't replicate the problem.

$ mvn verify
$ mvn javafx:run

The application is successfully launched and displays an icon at the center.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants