1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
   |  
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
 
 
public class Test extends JFrame {
 
    /**
     * @param args
     */
 
    final static int width = 400;
    final static int length = 400;
 
 
    public Test () {
        setTitle("Erste Gui Fenster");
        setSize (width, length);
        GridBagLayout layout = new GridBagLayout();
 
        setLayout(new GridBagLayout());
 
        JPanel pnl = new JPanel(layout);
 
 
        GridBagConstraints cons = new GridBagConstraints();
        cons.gridx =1;
        cons.gridy =2;
        cons.anchor = GridBagConstraints.LINE_END;
        JButton start = new JButton("start");
        getContentPane().add(start,cons);
 
        GridBagConstraints c = new GridBagConstraints();
        JLabel texte1 = new JLabel("Servername:");
        c.anchor = GridBagConstraints.LINE_START;
        c.gridx = 1;
        c.gridy = 1;
        pnl.add(texte1, c);
        JLabel texte2 = new JLabel("Rechnerprogramme:");
        c.gridy = 2;
        pnl.add(texte2, c);
        JLabel texte3 = new JLabel("User:");
        c.gridy = 3;
        pnl.add(texte3, c);
        JLabel texte4 = new JLabel("Passwort:");
        c.gridy = 4;
        pnl.add(texte4, c);
 
 
 
 
 
        JTextField eingabe1 = new JTextField();
        eingabe1.setPreferredSize(new Dimension(200,20));
        c.gridx = 2;
        c.gridy = 1;
        pnl.add(eingabe1,c);
        JTextField eingabe2 = new JTextField();
        eingabe2.setPreferredSize(new Dimension(200,20));
        c.gridy = 2;
        pnl.add(eingabe2, c);
        JTextField eingabe3 = new JTextField();
        eingabe3.setPreferredSize(new Dimension(200,20));
        c.gridy = 3;
        pnl.add(eingabe3, c);
        JPasswordField passwordField = new JPasswordField();
        passwordField.setPreferredSize(new Dimension(200,20));
        c.gridy = 4;
        pnl.add(passwordField, c);
 
        setVisible(true);
        cons.gridy = 1;
        cons.anchor = GridBagConstraints.LINE_START;
        getContentPane().add(pnl,cons);
 
 
 
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new Test();
 
    }
 
} | 
Partager