Layout Probleme in awt Applet

r_maniac

Grünschnabel
Guten tag.

Ich schreibe momentan ein awt applet für kleines netzwerk spiel... dabei habe ich an ein problem gestossen:
hier:
Code:
	private ActionListener l;
	private Panel p;
	private Label [] highscore=new Label[20];
	public HighScore(ActionListener l) {
		this.l=l;
		p=new Panel();
		p.setBounds(1, 1, 599, 499);
		p.setBackground(new Color(0,0,0));
		p.setLayout(null);
		Label uberschrift=new Label("NetPong");
		uberschrift.setForeground(new Color(240,240,240));
		uberschrift.setFont(new Font("Dialog", 0, 18));
		uberschrift.setBounds(100, 20, 100, 30);
		//uberschrift.setVisible(true);
		p.add(uberschrift);
		for(int i=0; i<highscore.length;i++ ){
			highscore[i]=new Label();
			highscore[i].setBounds(200, 50+20*i, 200, 20);
			highscore[i].setForeground(new Color(240,240,240));
			p.add(highscore[i]);
		}
		p.add(addButon(l,"Main Menu",50,400,70,50));
		p.setVisible(true);
		
	}
	public Button addButon(ActionListener l,String Name,int x,int y,int width,int height){
		Button b=new Button(Name);
		b.addActionListener(l);
		b.setActionCommand(Name);
		b.setBounds(x, y, width, height);
		return b;
	}
	public Panel getHighscorePanel(){
		return p;
	}
	public void setScore(String[] scores){
		for(int i=0;i<scores.length;i++){
			highscore[i].setText( scores[i]);
			System.out.println(scores[i]);
		}
	}
}
und hier:
Code:
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionListener;
import java.util.Vector;


public class MainMenu {
	private Panel p=new Panel();
	
	private ActionListener l;
	public MainMenu(ActionListener l){
		 p.setBounds(1, 1, 599, 499);
		 p.setLayout(null);
		this.l=l;
		p.add(addButon(l,"New Game",100,100,100,30));
		p.add(addButon(l,"Highscore",100,140,100,30));
		Label uberschrift=new Label("NetPong");
		uberschrift.setForeground(new Color(240,240,240));
		uberschrift.setFont(new Font("Dialog", 0, 18));
		uberschrift.setBounds(100, 20, 100, 30);
		p.add(uberschrift);
	}
	public Button addButon(ActionListener l,String Name,int x,int y,int width,int height){
		Button b=new Button(Name);
		b.addActionListener(l);
		b.setActionCommand(Name);
		b.setBounds(x, y, width, height);
		return b;
	}
	
	public Panel getmain(){
		return p;
	}
}
werden zwei panelen generiert; die in applet class aufegrufen werden:
Code:
public class ApletProto extends Applet implements Runnable,ActionListener, MouseMotionListener{
..... 
    public init(){
           ............
           mainPanel=main.getmain();
	add(mainPanel);
	highscorePanel=highScore.getHighscorePanel();
	add(highscorePanel);
}
.........
public void actionPerformed(ActionEvent arg0) {
		String command=arg0.getActionCommand();
		if(command.equals("New Game")){
			mainPanel.setVisible(false);
			startnewGame();
		}
		if(command.equals("Main Menu")){
			highscorePanel.setVisible(false);
			mainPanel.setVisible(true);
		}
		if(command.equals("Highscore")){
			Client.Sendline("@highscore:");
			mainPanel.setVisible(false);
			highscorePanel.setVisible(true);
		}
		
	}
...
}
main panel ist dabei sichtbar. Wenn ich zur highscore panewechseln versuche ist sie leider nicht. Könnte vieleicht mir jemand erklären was ich so falsch mache, und warum dieser code nicht funktioniert wie ich wolte
 
Zurück