In my function called create() i am trying to instanciate an object of class note, which is an extention of JLabel. I then want to add this object to a JLayeredPane (known as lp) at depth 1, in order to show it above my background image. Instanciation goes fine but the newNote object is not displayed.
Here is the code for the note class:
import javax.swing.ImageIcon;
import javax.swing.JLabel;
//This class will be used to instanciate new notes for the user
public class note extends JLabel{
final static ImageIcon image = new ImageIcon(note.class.getResource("semibreve1-removebg-preview.png"));
//attributes
private String length;
private String note1;
private String code;
private String val;
//Constructor
note(String myLength, String myNote){
super("",image,LEADING);
this.length = myLength;
this.note1 = myNote;
generateCode();
//System.out.println("note creation confirmed: "+code);
}
//Getters and setters below
And here is the code for my create function.
public void create(l,n){
note newNote = new note(l,n);
noteObjects.add(newNote);
newNote.setBounds(0,0,newNote.image.getIconWidth(),newNote.image.getIconHeight());
newNote.setSize(newNote.getPreferredSize());
lp.add(newNote,1);
}
Thanks for your time.
