S
Swing Anfänger
Gast
Hi ,
Ich bin neu in Java und frag mich grade warum die Buttons nicht da liegen ,wo sie sollten :
Ich bin neu in Java und frag mich grade warum die Buttons nicht da liegen ,wo sie sollten :
Code:
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class bla extends JFrame {
public bla(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(500, 500);
this.setTitle("Login");
JPanel mainPanel = new JPanel();
JLabel Username =new JLabel("Username");
JLabel Password =new JLabel("Password");
JButton Login = new JButton("Login");
JButton Abbrechen = new JButton("Abbrechen");
JButton Registrieren = new JButton("Registrieren");
mainPanel.add(Username);
mainPanel.add(Login);
mainPanel.add(Abbrechen);
mainPanel.add(Registrieren);
Login.setBounds(50, 100, 100, 20);
Abbrechen.setBounds(150, 100, 100, 20);
Registrieren.setBounds(80,130,150,20);
Username.setLocation(50, 50);
Username.setLocation(50, 70);
this.add(mainPanel);
this.setLocation(200, 200);
this.setVisible(true);
}
}