Wo und wie rufst Du den Konstruktor von View auf? Hast Du dort ein Model-Objekt erzeugt/zur Verfügung?
[CODE lang="java" highlight="15-17, 35,86-87"]import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import java.awt.GridLayout;
import java.util.Random;
import javax.swing.ImageIcon;
/**
* Die View ist das Fenster des Programms. Hier werden sowohl das optische Spielfeld und Buttons erzeugt, als auch Befehle entgegengenommen und weitergeleitet.
*
* @author (Ben Bertram)
* @version (17.06.2021)
*/
public class View extends JFrame implements ActionListener{
Control ctrl;
Model mdl;
JButton hoch = new JButton("hoch");
JButton runter = new JButton("runter");
JButton rechts = new JButton("rechts");
JButton links = new JButton("links");
JButton würfeln = new JButton("würfeln");
public int würfelwert = 0;
JPanel Spielfeld= new JPanel();
public JButton[]btns= new JButton[100];
public String[]cmds ={"btn0","btn1","btn2","btn3","btn4","btn5","btn6","btn7","btn8","btn9","btn10","btn11","btn12","btn13","btn14","btn15","btn15","btn17","btn18","btn19","btn20","btn21","btn22","btn23","btn24","btn25","btn26","btn27","btn28","btn29","btn30","btn31","btn32","btn33","btn34","btn35","btn36","btn37","btn38","btn39","btn40","btn41","btn42","btn43","btn44","btn45","btn46","btn47","btn48","btn49","btn50","btn51","btn52","btn53","btn54","btn55","btn56","btn57","btn58","btn59","btn60","btn61","btn62","btn63","btn64","btn65","btn66","btn67","btn68","btn69","btn70","btn71","btn72","btn73","btn74","btn75","btn676","btn77","btn78","btn79","btn80","btn81","btn82","btn83","btn84","btn85","btn86","btn87","btn88","btn89","btn90","btn91","btn92","btn93","btn94","btn95","btn96","btn97","btn98","btn99"};
public ImageIcon image1;
public ImageIcon image2;
/**
* Diese Methode erzeugt eine neue View und mit ihr ein 10x10 Spielfeld mit Knöpfen darauf, 4 Richtungsknöpfe und einen Würfeln-Knopf.
*
* @param keiner
* @return nichts
*/
public View(Control con, Model model){
super();
setSize(2000,1200);
setTitle("Räuber und Gendarme");
setVisible(true);
Spielfeld.setLayout(new GridLayout(10,10));
Spielfeld.setBounds(0,0,1000,1000);
add(Spielfeld);
hoch.setActionCommand("u");
hoch.addActionListener(this);
hoch.setBounds(1400,0,300,300);
add(hoch);
runter.setActionCommand("d");
runter.addActionListener(this);
runter.setBounds(1400,300,300,300);
add(runter);
rechts.setActionCommand("r");
rechts.addActionListener(this);
rechts.setBounds(1700,300,300,300);
add(rechts);
links.setActionCommand("l");
links.addActionListener(this);
links.setBounds(1000,300,300,300);
add(links);
würfeln.setActionCommand("dice");
würfeln.addActionListener(this);
würfeln.setBounds(1700,700,300,300);
add(würfeln);
for(int i=0;i<100;i++){
btns
=new JButton();
Spielfeld.add(btns);
btns.setActionCommand(cmds);
btns.addActionListener(this);
btns.setEnabled(true);
}
image1=new ImageIcon("Gendarme.jpg");
image1.setImage(image1.getImage().getScaledInstance(100,100,100));
btns[0].setIcon(image1);
image2=new ImageIcon("Raeuber.jpg");
image2.setImage(image2.getImage().getScaledInstance(100,100,100));
btns[9].setIcon(image2);
this.ctrl= con;
this.mdl= model;
}[/CODE]