Java examples for Swing:JLabel
Set Horizontal Alignment of JLabel
import javax.swing.JLabel; public class Main { public void init() { JLabel label1 = new JLabel("JLabel Set Horizontal Alignment Example."); /*/*w w w. java2 s .co m*/ * alignment is one of the following constants, LEFT, CENTER, RIGHT, LEADING or * TRAILING. */ label1.setHorizontalAlignment(JLabel.CENTER); } }