Hallo nochmals,
habe nun etwas mit dem GridBagLayout probiert, doch es wird lediglich ein Quadrat angezeigt, was ist nun falsch?
Danke für jegliche Hilfe?
[code=Java]
public class View extends JFrame{
public View(){
super("GridBagLayout Test");
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
setLayout(new BorderLayout());
JPanel raster = new JPanel(new GridBagLayout());
Tile[][] tiles = new Tile[20][20];
GridBagConstraints c = new GridBagConstraints();
Tile tile;
for(int i=0; i<20; ++i){
for(int j=0; j<20; ++j){
c.gridx = i;
c.gridy = j;
tile = new Tile();
raster.add(tile, c);
tiles[i][j] = tile;
}
}
add(raster, BorderLayout.CENTER);
setVisible(true);
}
private class Tile extends JComponent{
protected void paintComponent(Graphics g){
g.fillRect(0, 0, 50, 50);
}
public Dimension getPreferredSize(){
return new Dimension(50, 50);
}
}
}
[/code]