import java.awt.*;
import java.awt.event.*;
import java.util.Observable;
import java.util.Observer;
import javax.swing.*;
import javax.swing.event.*;
public class PaintPanel extends JPanel implements Observer {
GridBagConstraints c = new GridBagConstraints();
JPanel clock = new Clockpanel();
MessagePanel clock2 = new MessagePanel();
Model m;
ControlerMain controler;
EinstellungsPanel einstellung;
UebersichtPanel uebersicht;
PlanungPanel planung;
PaintPanel(Model m,ControlerMain co)
{
this.m=m;
this.controler=co;
setLayout(new GridBagLayout());
c.insets = new Insets(10, 10, 10, 10);
c.fill = GridBagConstraints.BOTH; // components grow in both dimensions
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 5;
c.weightx = c.weighty = 0.9;
clock.setOpaque(true);
this.add(clock, c);
this.einstellung = new EinstellungsPanel(controler);
this.uebersicht= new UebersichtPanel(controler,m);
this.planung= new PlanungPanel(controler,m);
c.gridx = 0;
c.gridy = 6;
c.gridwidth = 2;
c.gridheight = 1;
c.weightx = c.weighty = 0.1;
m.addObserver(this);
this.add(clock2, c);
}
public void update(Observable observable, Object arg) {
if((((Model)observable).selectedButton==1)&&!(clock instanceof EinstellungsPanel)){
//clock.setVisible(false);
clock.removeAll();
clock=einstellung;
if (clock!=null)System.out.println(clock);
c.insets = new Insets(10, 10, 10, 10);
c.fill = GridBagConstraints.BOTH; // components grow in both dimensions
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 5;
c.weightx = c.weighty = 0.9;
//clock.setBackground(Color.orange);
clock.setOpaque(true);
this.add(clock, c);
repaint();
}
if((((Model)observable).selectedButton==2)&&!(clock instanceof UebersichtPanel)){
clock.removeAll();
clock= uebersicht;
if (clock!=null)System.out.println(clock);//clock=new UebersichtPanel(controler,m);
c.insets = new Insets(10, 10, 10, 10);
c.fill = GridBagConstraints.BOTH; // components grow in both dimensions
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 5;
c.weightx = c.weighty = 0.9;
//clock.setBackground(Color.orange);
clock.setOpaque(true);
this.add(clock, c);
repaint();
}
if((((Model)observable).selectedButton==3)&&!(clock instanceof PlanungPanel)){
clock.removeAll();
clock= planung;
if (clock!=null)System.out.println(clock);
c.insets = new Insets(10, 10, 10, 10);
c.fill = GridBagConstraints.BOTH; // components grow in both dimensions
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 5;
c.weightx = c.weighty = 0.9;
//clock.setBackground(Color.orange);
clock.setOpaque(true);
this.add(clock, c);
repaint();
}
}
}