首页 > 其他 > 详细

e740. 向标签中加入一个图标

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

This example creates a JLabel component with an icon.

    // Fetch icon
    Icon icon = new ImageIcon("icon.gif");
    
    // Create a label with text and an icon; the icon appears to the left of the text
    JLabel label = new JLabel("Text Label", icon, JLabel.CENTER);
    
    // Create a label with only an icon
    label = new JLabel(icon);

This example adds or replaces the icon in an existing JLabel component:

    // Add an icon to an existing label
    label.setIcon(icon);

The methods to control the position of the icon and text within a JLabel component are identical to those of a JButton. See also e747 在按钮上移动图标的位置, e748 在按钮上移动图标和标注的位置, e749 设置按钮上图标和标注的间隔, and e750 在按钮上加上不可用图标

e740. 向标签中加入一个图标

原文:https://www.cnblogs.com/borter/p/9596123.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!