Hey danke schonmal.
Hier einmal der vollständige code des Frames ohne den Einsatz des ScrollPanes.
[code=Java]/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package nl.fontys.sevenlo.prj32.gui;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author Lukas
*/
public class ShaftGroupFrame extends JFrame {
private ShaftPanel[] shaftPanels;
private int shafts, floors, width, height;
private Color bgColor;
private static JPanel bgPanel;
private static ShaftGroupFrame instance = null;
private GuiValues values = GuiValues.getInstance();
private JScrollPane scroll;
private ShaftGroupFrame() {
bgPanel = new JPanel();
this.add(bgPanel);
}
public static ShaftGroupFrame getInstance() {
if (instance == null) {
instance = new ShaftGroupFrame();
}
return instance;
}
private void setLayout() {
this.setLayout(null);
this.setVisible(true);
this.setSize(width + 10, height + 30);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
bgPanel.setLayout(null);
bgPanel.setBackground(bgColor);
bgPanel.setSize(this.getWidth(), this.getHeight());
}
private void createComponents() {
for (int i = 0; i < shafts; i++) {
shaftPanels[i] = new ShaftPanel(i);
}
}
private void addComponents() {
for (int i = 0; i < shafts; i++) {
bgPanel.add(shaftPanels[i]);
shaftPanels[i].setBounds(i * 360, 10, 330, this.getHeight());
}
}
public JPanel getDoorPanel(int shaft, int currentFloor) {
return shaftPanels[shaft].getDoorPanel(currentFloor);
}
public JPanel getFloorPanel(int shaft, int currentFloor) {
return shaftPanels[shaft].getFloorPanel(currentFloor);
}
public JPanel getShaft(int shaftNumber){
return shaftPanels[shaftNumber];
}
public void update() {
//Save values
this.shafts = values.getShafts();
this.floors = values.getFloors();
this.bgColor = values.getColor();
this.height = floors * 450;
this.width = shafts * 370;
//Reconfigure whole panel
setLayout();
bgPanel.removeAll();
bgPanel.repaint();
shaftPanels = new ShaftPanel[shafts];
createComponents();
addComponents();
repaint();
}
}
[/code]
Damit sind vielleicht ein paar unklarheiten ausgeräumt?!?
Dem bgPanel werden Dinge hinzugefügt in der MEthode addComponents();
ICh weiss jetzt leider nicht genau, wie ich das jetzt genau machen soll. :-(