i have created a form application with an image that is displayed using the icon property in the label
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/replacment.jpg"))); // NOI18N
getContentPane().add(jLabel2);
jLabel2.setBounds(640, 220, 68, 30);
the main idea is when the user presses a certain button , the image would disappear like this
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("")));
}
And it works successfully , I tried to use the getIcon function to alter the code of the program depending on the image displayed in the label , for example
if(jLabel2.getIcon()==""){
do something
}
but i get an error saying : incomparable types Java.swing.icon and Java.lang.string.
so is there a way to do an if statement depending on the icon displayed by the Label?