JLabel text zentrieren

Shizzl_chrizzl

Erfahrenes Mitglied
Hallo,

wie kann man den den Text eines JLabels zentrieren. Normalerweise wird er ja immer rechtsbündig ausgerichtet... Ich möchte aber nicht das JLabel verschieben, sonder nur den Text auf dem JLabel.
 
:google:

public void setHorizontalAlignment(int alignment)
Sets the alignment of the label's contents along the X axis.

This is a JavaBeans bound property.

Parameters:
alignment - One of the following constants defined in SwingConstants: LEFT, CENTER (the default for image-only labels), RIGHT, LEADING (the default for text-only labels) or TRAILING.


public void setHorizontalTextPosition(int textPosition)
Sets the horizontal position of the label's text, relative to its image.

Parameters:
textPosition - One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING, or TRAILING (the default).
 
Zurück