1

Sorry to ask such a dumb question, but I can't figure out why this is crashing. I'm just trying to add a JLabel on top of my JPanel. The JLabel simply is there to display an image. I'm getting a NullPointerException.

(prediction: this is going to wind up being one of those "duh" moments.)

public JDlgTable() {
        ImageIcon myImg = new ImageIcon("image.png");
        JLabel myLabel = new JLabel(myImg);        
        myPanel.add(myLabel);   <-- error happens here
    }

Thanks.

4

0 回答 0