V
vanny
Gast
kann jemand erkennen, warum die Bilder nicht angezeigt werden?
Java:
import java.awt.*;
import javax.swing.*;
public class Gui extends JFrame{
private String[] pfad = new String[9];
private Icon[] icons = new ImageIcon[9];
private JLabel[] lab = new JLabel[9];
private JPanel pan = new JPanel();
public Gui(){
this.getContentPane();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
this.setSize(622, 121);
this.setLocationRelativeTo(null);
this.setLayout(null);
pan.setLayout(new FlowLayout());
pan.setBounds(0,0,622,121);
for(int i=0;i<9;i++){
pfad[i] = "bild_0"+(i+1)+".jpg";
icons[i] = new ImageIcon(pfad[i]);
lab[i] = new JLabel();
lab[i].setIcon(icons[i]);
pan.add(lab[i]);
System.out.printf("%s\n", pfad[i]);
}
this.add(pan);
this.setVisible(true);
this.repaint();
}
}