I am trying to add a button over the image. But neither see the button nor the image. Why is that ? I am calling this method from the constructor just after the initComponents
method is called by the IDE.
public void initD() {
try {
BufferedImage myPicture = ImageIO.read(new File("C:\\Users\\user\\Documents\\NetBeansProjects\\JavaApplication1\\src\\javaapplication1\\meaning.JPG"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
JButton b = new JButton("Press me");
jPanel1.add(picLabel);
jPanel1.add(b);
System.out.println("last statement");
}catch(Exception exc) {
exc.printStackTrace();
}
}
I only see the frame as an output.