Set Horizontal Alignment of JLabel - Java Swing

Java examples for Swing:JLabel

Description

Set Horizontal Alignment of JLabel

Demo Code


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);
  }
}

Related Tutorials