Hallo zusammen,
ich bring es mal direkt auf den Punkt:
Man soll auf einen der drei Buttons klicken und dann soll sich die Hintergrund- und Vordergrundfarbe vom Center ändern und darauf ein
Label sichtbar werden.
Doch es erscheint kein Label, nur die Farbe ändert sich.
|
C-/C++-Quelltext
|
1
|
public void actionPerformed(ActionEvent e) { Object cmd = e.getSource(); if( cmd == btRot) { pnCenter.setBackground(Color.red); pnCenter.setForeground(Color.white); pnCenter.add(new Label("TÜRKEI")); } else if( cmd == btGelb) { pnCenter.setBackground(Color.yellow); pnCenter.setForeground(Color.green); pnCenter.add(new Label("BRASILIEN")); } else if( cmd == btBlau) { pnCenter.setBackground(Color.blue); pnCenter.setForeground(Color.yellow); pnCenter.add(new Label("SCHWEDEN")); } }
|
edit: Sorry, iwie formatiert er den Code immer wieder hintereinander. :/
public void actionPerformed(ActionEvent e)
{
Object cmd = e.getSource();
if( cmd == btRot)
{
pnCenter.setBackground(Color.red);
pnCenter.setForeground(Color.white);
pnCenter.add(new Label("TÜRKEI"));
}
else if( cmd == btGelb)
{
pnCenter.setBackground(Color.yellow);
pnCenter.setForeground(Color.green);
pnCenter.add(new Label("BRASILIEN"));
}
else if( cmd == btBlau)
{
pnCenter.setBackground(Color.blue);
pnCenter.setForeground(Color.yellow);
pnCenter.add(new Label("SCHWEDEN"));
}
}