public class Startview1 extends JFrame implements Observer, MouseListener, ChangeListener, WindowListener{
Startmodel startmodel;
private static TextField spieler1; //tab neuesSpiel
private static TextField spieler2;
private static JComboBox breite = new JComboBox();
private static JComboBox hoehe = new JComboBox();
private String[] anzahlKaestchen = {"4","5","6","7", "8", "9", "10"}; //Fuellung fuer die JComboBox
private JButton spielStarten;
private JButton abbrechen;
...
static JTabbedPane tabs;
public Startview1(Startmodel sm){
startmodel = sm;
Container ct1 = this.getContentPane();
setTitle("Kaesekaestchen");
/*
* Register erstellen als neue Panels
*/
JPanel neuesSpiel = new JPanel();
JPanel spielLaden = new JPanel();
JPanel spielfeld = new JPanel();
JPanel anLeitung = new JPanel();
/*
* Pane erstellen, die ihre Registerkarte oben ausgerichtet hat
*/
JTabbedPane tabs = new JTabbedPane();
/*
* Panels (Register) zur Pane hinzufügen
*/
tabs.addTab(null, neuesSpiel);
tabs.setTabComponentAt(0, new JLabel("Neues Spiel"));
tabs.addTab(null, spielLaden);
tabs.setTabComponentAt(1, new JLabel("Spiel laden"));
tabs.addTab(null, spielfeld);
tabs.setTabComponentAt(2, new JLabel("Spielfeld"));
tabs.addTab(null, anLeitung);
tabs.setTabComponentAt(3, new JLabel("Anleitung"));
/*
* Register "neues Spiel"
*/
neuesSpiel.setLayout(new GridLayout(5, 3, 10, 10));
JLabel jl1;
neuesSpiel.add(jl1 = new JLabel("Spieler 1: "));
neuesSpiel.add(spieler1 = new TextField("Name?"));
spieler1.setName("Spieler1");
spieler1.addMouseListener(this);
spieler1.addActionListener(new Startcontroller(this));
JLabel jl2;
neuesSpiel.add(jl2 = new JLabel(" Farbe: rot / Zeichen: X"));
jl2.setBorder(new LineBorder (Color.red, 2));
neuesSpiel.add(new JLabel("Spieler 2: "));
neuesSpiel.add(spieler2 = new TextField("Name?"));
spieler2.setName("Spieler2");
spieler2.addMouseListener(this);
spieler2.addActionListener(new Startcontroller(this));
JLabel jl3;
neuesSpiel.add(jl3 = new JLabel(" Farbe: blau / Zeichen: O"));
jl3.setBorder(new LineBorder (Color.blue, 2));
neuesSpiel.add(new JLabel("Spielfeldgröße: "));
breite.setName("breite");
breite = new JComboBox(anzahlKaestchen);
neuesSpiel.add(breite);
breite.addActionListener(new Startcontroller (this));
neuesSpiel.add(new JLabel("= Breite"));
neuesSpiel.add(new JLabel("" ));
hoehe = new JComboBox(anzahlKaestchen);
hoehe.setName("hoehe");
hoehe.setEnabled(false);
neuesSpiel.add(hoehe);
neuesSpiel.add(new JLabel("= Hoehe"));
neuesSpiel.add(new JLabel(""));
neuesSpiel.add(spielStarten = new JButton("Spiel starten"));
spielStarten.setName("spielStart");
neuesSpiel.add(abbrechen = new JButton("Abbrechen"));
abbrechen.setName("abbrechen");
spielStarten.addActionListener(new Startcontroller (this));
abbrechen.addActionListener(new Startcontroller (this));