Hallo,
Könnt ihr mir bitte helfen irgendwie finde ich mein flasche Klammer Setzungen:
Könnt ihr mir bitte helfen irgendwie finde ich mein flasche Klammer Setzungen:
Java:
//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);
final JTextField username = new JTextField("Username",30);
final JPasswordField passwort = new JPasswordField("Passwort",30);
final JButton fertig = new JButton("Login");
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
oMainWindow.add(panel);
oMainWindow.add(panel,BorderLayout.SOUTH);
oMainWindow.add(z,BorderLayout.NORTH);
z.setHorizontalAlignment(JLabel.CENTER);
z.setVerticalAlignment(JLabel.TOP);
z.setFont(new Font("Flubber", Font.BOLD + Font.ITALIC, 60));
panel.add(username);
panel.add(passwort);
panel.add(fertig);
}
else
{
final JLabel y = new JLabel("Server 2 Erde");
oMainWindow.add(y);
final JTextField username = new JTextField("Username",30);
final JPasswordField passwort = new JPasswordField("Passwort",30);
final JButton fertig = new JButton("Login");
final JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
//panel.setSize(1280,80);
oMainWindow.add(y,BorderLayout.NORTH);
y.setHorizontalAlignment(JLabel.CENTER);
y.setVerticalAlignment(JLabel.TOP);
oMainWindow.add(panel);
oMainWindow.add(panel,BorderLayout.SOUTH);
panel.add(username);
panel.add(passwort);
panel.add(fertig);
y.setFont(new Font("Flubber", Font.BOLD + Font.ITALIC, 60));
fertig.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent g) {
if(richtig == 1)
{
username.setVisible(false);
passwort.setVisible(false);
fertig.setVisible(false);
panel.setVisible(false);
y.setVisible(false);
}
{
JOptionPane fehler = JOptionPane.showMessageDialog(null, "Login felgeschlagen.Bitte Versuche es Erneut", "Error", JOptionPane.ERROR_MESSAGE);
}
}
});
oMainWindow.setSize(1280, 768);
}
}
});
}
oMainWindow.add(login,BorderLayout.CENTER);
oMainWindow.setVisible(true); // sollte am Schluss aufgerufen werden
});
}