ImageIcon loads no image
        Posted  
        
            by neville
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by neville
        
        
        
        Published on 2010-05-09T23:27:05Z
        Indexed on 
            2010/05/09
            23:38 UTC
        
        
        Read the original article
        Hit count: 250
        
I'm trying to get image built from tiled set of images So to JPanel I'm adding JButtons with ImageIcons. All images are in folder with my classes (NetBeans), and they're named u1, u2, ..., u16. But on button there is no image shown. What am I doing wrong ?
   JPanel panel = new JPanel(new GridLayout(4, 4, 3, 3)); 
   for (int i = 1; i < 17; i++) {
        JLabel l = new JLabel(new ImageIcon("u"+i+".jpg"), JLabel.CENTER);
        l.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        panel.add(l);
    }
© Stack Overflow or respective owner