码迷,mamicode.com
首页 > 其他好文 > 详细

e739. 创建一个标签组件

时间:2018-09-06 10:55:05      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:body   color   red   pre   top   col   ted   标签   cin   

    // The text is left-justified and vertically centered
    JLabel label = new JLabel("Text Label");
    
    // The text is horizontally and vertically centered
    label = new JLabel("Text Label", JLabel.CENTER);
    
    // The text is right-justified and vertically centered
    label = new JLabel("Text Label", JLabel.RIGHT);
    
    // The text is left-justified and top-aligned
    label = new JLabel("Text Label", JLabel.LEFT);
    label.setVerticalAlignment(JLabel.TOP);
    
    // The text is right-justified and top-aligned
    label = new JLabel("Text Label", JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.TOP);
    
    // The text is left-justified and bottom-aligned
    label = new JLabel("Text Label", JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    
    // The text is right-justified and bottom-aligned
    label = new JLabel("Text Label", JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.BOTTOM);

 

Related Examples

e739. 创建一个标签组件

标签:body   color   red   pre   top   col   ted   标签   cin   

原文地址:https://www.cnblogs.com/borter/p/9596121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!