//package dumb;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class game { // Erster Buchstabe einse Klassennamens sollte groß geschrieben sein
public static void main(String args[]) {
final JFrame oMainWindow = new JFrame("World of War"); // muss "final" sein, damit es im ActionListener benutzt werden kann.
oMainWindow.setSize(500, 200);
oMainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final JLabel hallo = new JLabel("World of War");
hallo.setHorizontalAlignment(JLabel.CENTER);
hallo.setVerticalAlignment(JLabel.TOP);
hallo.setFont(new Font("Flubber", Font.BOLD + Font.ITALIC, 60));
// hallo.setVisible(true); braucht nicht extra aufgerufen werden
oMainWindow.add(hallo,BorderLayout.NORTH);
final JButton login = new JButton("Zum Login");
login.setPreferredSize(new Dimension(17, 17));
login.setBorderPainted(false);
oMainWindow.add(login,BorderLayout.CENTER);
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
login.setVisible(false);
login.remove(oMainWindow);
final JComboBox Server = new JComboBox();
Server.addItem("S1 Neptun");
Server.addItem("S2 Erde");
oMainWindow.add(Server);
final JButton Weiter = new JButton("Weiter");
oMainWindow.add(Weiter);
oMainWindow.add(Server,BorderLayout.CENTER);
oMainWindow.add(Weiter,BorderLayout.SOUTH);
Weiter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
Server.setVisible(false);
Weiter.setVisible(false);
hallo.setVisible(false);
String serverwahl = (String)Server.getSelectedItem ();
if(serverwahl == "S1 Neptun")
{
JLabel z = new JLabel("Server 1 Neptun");
oMainWindow.add(z);
oMainWindow.add(z,BorderLayout.NORTH);
z.setHorizontalAlignment(JLabel.CENTER);
z.setVerticalAlignment(JLabel.TOP);
z.setFont(new Font("Flubber", Font.BOLD + Font.ITALIC, 60));
}
else
{
JLabel y = new JLabel("Server 2 Erde");
oMainWindow.add(y);
final TextField username = new TextField("Username",30);
final TextField passwort = new TextField("Passwort",30);
username.setSize(1280, 10);
oMainWindow.add(username);
oMainWindow.add(passwort);
oMainWindow.add(y,BorderLayout.NORTH);
oMainWindow.add(username,BorderLayout.CENTER);
oMainWindow.add(passwort,BorderLayout.SOUTH);
y.setHorizontalAlignment(JLabel.CENTER);
y.setVerticalAlignment(JLabel.TOP);
y.setFont(new Font("Flubber", Font.BOLD + Font.ITALIC, 60));
}
oMainWindow.setSize(1280, 768);
}
});
}
});
oMainWindow.add(login,BorderLayout.CENTER);
oMainWindow.setVisible(true); // sollte am Schluss aufgerufen werden
}
}