BoxLayout?

Status
Nicht offen für weitere Antworten.
G

Guest

Gast
Hallo,

ich nutze für eine Einstellungsseite das BoxLayout. Leider funktioniert es nicht wie gewünscht.
Ich habe ein PanelProxy auf dem ich eine VerticalBox platziere. In der Box sind jeweils Panels mit Label + Textfeld für verschiedene Proxyeinstellungen. Jetzt sehe ich auf dem panelProxy jedoch nur das letzte Feld (Passwortfeld). Die anderen sind nicht da, bzw. sind vermutlich darunter.

Ich dachte beim BoxLayout würde er immer eine Box unten dran hängen. Oder habe ich irgendwo ein Fehler?

Code:
this.getContentPane().setLayout(new BorderLayout());
		
		Box bv = Box.createVerticalBox();
		
		JPanel panelProxy = new JPanel(new BorderLayout());
		Box boxProxy = Box.createVerticalBox();
	    Border borderProxy = BorderFactory.createTitledBorder("Proxy");
	    panelProxy.setBorder(borderProxy);
	    
	    JPanel panelProxyHost = new JPanel(new BorderLayout());
	    JLabel labelProxyHost = new JLabel("Host");
	    JTextField textProxyHost = new JTextField();
	    panelProxyHost.add(labelProxyHost, BorderLayout.WEST);
	    panelProxyHost.add(textProxyHost, BorderLayout.CENTER);
	    boxProxy.add(panelProxyHost);
	    
	    JPanel panelProxyPort = new JPanel(new BorderLayout());
	    JLabel labelProxyPort = new JLabel("Port");
	    JTextField textProxyPort = new JTextField();
	    panelProxyHost.add(labelProxyPort, BorderLayout.WEST);
	    panelProxyHost.add(textProxyPort, BorderLayout.CENTER);
	    boxProxy.add(panelProxyPort);
	    
	    JPanel panelProxyUser = new JPanel(new BorderLayout());
	    JLabel labelProxyUser = new JLabel("Benutzername");
	    JTextField textProxyUser = new JTextField(); 
	    panelProxyHost.add(labelProxyUser, BorderLayout.WEST);
	    panelProxyHost.add(textProxyUser, BorderLayout.CENTER);
	    boxProxy.add(panelProxyUser);
	    
	    JPanel panelProxyPass = new JPanel(new BorderLayout());
	    JLabel labelProxyPass = new JLabel("Passwort");
	    JPasswordField passProxyPass = new JPasswordField();
	    panelProxyHost.add(labelProxyPass, BorderLayout.WEST);
	    panelProxyHost.add(passProxyPass, BorderLayout.CENTER);
	    boxProxy.add(panelProxyPass);
	 
	    panelProxy.add(boxProxy, BorderLayout.CENTER);
	    bv.add(panelProxy);
	    
	    
	    add(bv,BorderLayout.CENTER);
	    
	    JButton save = new JButton("Speichern");
	    add(save,BorderLayout.SOUTH);
	    
	    this.setLocationRelativeTo(null);
	    this.pack();
	    this.setVisible(true);
	    setSize(300, 400);

P.S.: Warum ist eigentlich das Wort Layout auf der Spamliste?
[Edit by Beni: Titel]
 

Marco13

Top Contributor
panelProxyHost.add(labelProxyPort, BorderLayout.WEST);
panelProxyHost.add(textProxyPort, BorderLayout.CENTER);
panelProxyHost.add(labelProxyUser, BorderLayout.WEST);
panelProxyHost.add(textProxyUser, BorderLayout.CENTER);
panelProxyHost.add(labelProxyPass, BorderLayout.WEST);
panelProxyHost.add(passProxyPass, BorderLayout.CENTER);

....
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
I BoxLayout zentriert Label nicht AWT, Swing, JavaFX & SWT 7
Z BoxLayout funktioniert nicht und Buttongröße AWT, Swing, JavaFX & SWT 18
R Swing panels nebeneinander mit BoxLayout.X_AXIS AWT, Swing, JavaFX & SWT 4
M BoxLayout AWT, Swing, JavaFX & SWT 6
T Swing Größe einer Komponente in einem BoxLayout / FlowLayout festlegen AWT, Swing, JavaFX & SWT 7
I BoxLayout, FlowLayout und Komponentengrößen AWT, Swing, JavaFX & SWT 1
S BoxLayout: Anordnung der Komponenten links statt zentriert AWT, Swing, JavaFX & SWT 0
S Bei BoxLayout haben hinzugefügten Jpanels einen Versatz/Space AWT, Swing, JavaFX & SWT 0
K BoxLayout-nicht teilbar AWT, Swing, JavaFX & SWT 6
apple987123 Swing BoxLayout AWT, Swing, JavaFX & SWT 3
G Problem mit Button im Boxlayout... AWT, Swing, JavaFX & SWT 4
F Swing BoxLayout ein JTextfield wird falsch positioniert AWT, Swing, JavaFX & SWT 2
T BoxLayout AWT, Swing, JavaFX & SWT 4
P LayoutManager Komponenten einfügen (FlowLayout, BoxLayout) AWT, Swing, JavaFX & SWT 2
R BoxLayout(Y_Axis) ignoriert preferedSize von Buttons AWT, Swing, JavaFX & SWT 5
B Probleme mit Layout Manager (BoxLayout) AWT, Swing, JavaFX & SWT 4
C Swing BoxLayout: Buttongröße AWT, Swing, JavaFX & SWT 10
F BoxLayout mit gleicher größe AWT, Swing, JavaFX & SWT 2
D Swing [BoxLayout] Nur TextArea und nicht TextField vergroessen AWT, Swing, JavaFX & SWT 2
G BoxLayout: Ausrichtung der Komponenten AWT, Swing, JavaFX & SWT 2
K BoxLayout skaliert die "falschen" Elemente AWT, Swing, JavaFX & SWT 5
hdi BoxLayout mit Abstand? AWT, Swing, JavaFX & SWT 5
spacegaier BoxLayout: Buttons auf gleiche Größe bringen AWT, Swing, JavaFX & SWT 4
J Wie kann man beim BoxLayout scrollen? Keine Scrollleiste!:-( AWT, Swing, JavaFX & SWT 7
H AWTError: BoxLayout can't be shared AWT, Swing, JavaFX & SWT 1
A Probleme mit JPanel und BoxLayout AWT, Swing, JavaFX & SWT 5
J JComboBox und BoxLayout AWT, Swing, JavaFX & SWT 2
D BoxLayout in GridBagLayout AWT, Swing, JavaFX & SWT 7
O BoxLayout AWT, Swing, JavaFX & SWT 3
G BoxLayout: Abstand zwischen vertikalen Komponenten! AWT, Swing, JavaFX & SWT 4

Ähnliche Java Themen

Neue Themen


Oben