[ 
https://issues.apache.org/jira/browse/NETBEANS-19?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jean-François El Fouly updated NETBEANS-19:
-------------------------------------------
    Description: 
An annoying and tricky little bug.

h1. Nominal scenario (NetBeans non-Maven project)
# File > New Project...
# Java | Java application (You could uncheck Create Main Class)
# New > JFrame Form...
# In the designer drag a JLabel
# For the icon property click "..."
# Click Import to Project...
# Choose an icon then Finish
# The icon is copied along the java source file
# Run
# Everybody happy. It works

h1. Maven project
# File > New Project...
# Maven | Java application
# New > JFrame Form...  (Default values OK)
# In the designer drag a JLabel
# For the icon property click "..."
# Click Import to Project...
# Choose an icon then Finish
# The icon is copied along the java source file
# Run
# It crashes with a NullPointerException

h2. Manual remediation
# In the project create src/main/resources
# Move the icon to this directory (same package as it was under src/main/java)
# NetBeans detects this and adds "Other Sources" to the project tree
# mvn clean (to force rebuild)
# Now it works

h1. Rationale
Importing an icon and associating to a JLabel generates code such as this:

bq. jLabel1.setIcon(new 
javax.swing.ImageIcon(getClass().getResource("/test/mavenproject1/bookmark.png")));
 // NOI18N

But the maven compiler plugin will not copy the icon to target/classes so 
target/classes contains the classes but not the image. So the code above causes 
a NPE.

h2.Bottom line
In a Maven project icons should not be imported to src/main/java but to 
src/main/resources, same package.

This small but annoying bug is not a regression: it can easily be reproduced in 
8.2


  was:
An annoying and tricky little bug.

h1. Nominal scenario (NetBeans non-Maven project)
# File > New Project...
#Java | Java application (You could uncheck Create Main Class)
#New > JFrame Form...
#In the designer drag a JLabel
#For the icon property click "..."
#Click Import to Project...
#Choose an icon then Finish
#The icon is copied along the java source file
#Run
#Everybody happy. It works

h1. Maven project
#File > New Project...
#Maven | Java application
#New > JFrame Form...  (Default values OK)
#In the designer drag a JLabel
#For the icon property click "..."
#Click Import to Project...
#Choose an icon then Finish
#The icon is copied along the java source file
#Run
#It crashes with a NullPointerException

h2. Manual remediation
#In the project create src/main/resources
#Move the icon to this directory (same package as it was under src/main/java)
#NetBeans detects this and adds "Other Sources" to the project tree
#mvn clean (to force rebuild)
#Now it works

h1. Rationale
Importing an icon and associating to a JLabel generates code such as this:

{{        jLabel1.setIcon(new 
javax.swing.ImageIcon(getClass().getResource("/test/mavenproject1/bookmark.png")));
 // NOI18N}}

But the maven compiler plugin will not copy the icon to target/classes so 
target/classes contains the classes but not the image. So the code above causes 
a NPE.

h2.Bottom line
In a Maven project icons should not be imported to src/main/java but to 
src/main/resources, same package.

This small but annoying bug is not a regression: it can easily be reproduced in 
8.2



> GUI Designer + Maven: icons imported in the wrong directory
> -----------------------------------------------------------
>
>                 Key: NETBEANS-19
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-19
>             Project: NetBeans
>          Issue Type: Bug
>          Components: apisupport - Maven, guibuilder - Code
>    Affects Versions: 8.2, 9.0
>         Environment: Windows 7 Professional
> JDK 1.8.0_111-b14
> Maven 3.3.3
>            Reporter: Jean-François El Fouly
>            Priority: Minor
>
> An annoying and tricky little bug.
> h1. Nominal scenario (NetBeans non-Maven project)
> # File > New Project...
> # Java | Java application (You could uncheck Create Main Class)
> # New > JFrame Form...
> # In the designer drag a JLabel
> # For the icon property click "..."
> # Click Import to Project...
> # Choose an icon then Finish
> # The icon is copied along the java source file
> # Run
> # Everybody happy. It works
> h1. Maven project
> # File > New Project...
> # Maven | Java application
> # New > JFrame Form...  (Default values OK)
> # In the designer drag a JLabel
> # For the icon property click "..."
> # Click Import to Project...
> # Choose an icon then Finish
> # The icon is copied along the java source file
> # Run
> # It crashes with a NullPointerException
> h2. Manual remediation
> # In the project create src/main/resources
> # Move the icon to this directory (same package as it was under src/main/java)
> # NetBeans detects this and adds "Other Sources" to the project tree
> # mvn clean (to force rebuild)
> # Now it works
> h1. Rationale
> Importing an icon and associating to a JLabel generates code such as this:
> bq. jLabel1.setIcon(new 
> javax.swing.ImageIcon(getClass().getResource("/test/mavenproject1/bookmark.png")));
>  // NOI18N
> But the maven compiler plugin will not copy the icon to target/classes so 
> target/classes contains the classes but not the image. So the code above 
> causes a NPE.
> h2.Bottom line
> In a Maven project icons should not be imported to src/main/java but to 
> src/main/resources, same package.
> This small but annoying bug is not a regression: it can easily be reproduced 
> in 8.2



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to