⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e740. adding an icon to a jlabel component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
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 Moving the Icon in a JButton Component, e748 Moving the Label/Icon Pair in a JButton Component, e749 Setting the Gap Size Between the Label and Icon in a JButton Component, and e750 Adding a Disabled Icon to a JButton Component. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -