JLabel immer zentriert

Status
Nicht offen für weitere Antworten.

newb

Mitglied
Hi Leute
Ich hab folgenden Programmcode:
[HIGHLIGHT="Java"]public class Fenster implements WindowListener{
private JFrame f;
private JLabel lab_Source;
public Fenster(String Name){
createWindow(Name);
}

public void createWindow(String Name){
f=new JFrame(Name);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 400);
f.setVisible(true);

lab_Source = new JLabel("Quelle:");
lab_Source.setVerticalTextPosition(JLabel.TOP);
f.add(lab_Source);
}[/HIGHLIGHT]

Mein Problem ist, dass wenn ich das Programm ausführe erscheint das JLabel immer vertikal zentriert in dem Fenster! Was mach ich da falsch?
 
Zuletzt bearbeitet von einem Moderator:
:rtfm:
API-Doc hat gesagt.:
public void setVerticalTextPosition(int textPosition)
Sets the vertical position of the label's text, relative to its image.

The default value of this property is CENTER.

This is a JavaBeans bound property.

Parameters:
textPosition - One of the following constants defined in SwingConstants: TOP, CENTER (the default), or BOTTOM.
See Also:
SwingConstants, getVerticalTextPosition()
Was Du suchst: JLabel.setVerticalAlignment(int)

Ebenius
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben