Friday, March 6, 2015

Vertical Alignment of JLabel in a java pgm



Set Vertical Alignment of JLabel

import javax.swing.JApplet;
import javax.swing.JLabel;
public class JLabelVerticalAlignmentExample extends JApplet
{
public void init()
{
JLabel label1 = new JLabel("JLabel Get Horizontal Alignment Example.");add(label1);
int alignment = label1.getVerticalAlignment();
switch(alignment)
{
case JLabel.LEFT:
label1.setText("Left");
break;
case JLabel.CENTER:
label1.setText("Center");
break;
case JLabel.RIGHT:
label1.setText("Right");
break;
case JLabel.LEADING:
label1.setText("Leading");
break;
case JLabel.TRAILING:
label1.setText("Trailing");
break;
     }
    }
  }

No comments:

Post a Comment