JLabel基本用法

 

import java.awt.FlowLayout;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class JLabelIcon extends JFrame{
	public JLabelIcon(){
		setSize(300,300);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new FlowLayout(FlowLayout.LEFT));
		
		Icon icon = new ImageIcon("E:\\java\\eclipse1\\JLabel\\bin\\44.png");
		
		JLabel label1 = new JLabel("用户名:" ,icon,JLabel.LEFT);
		JLabel label2 = new JLabel("密     码:" , JLabel.LEFT);
		label2.setIcon(new ImageIcon("E:\\java\\eclipse1\\JLabel\\bin\\66.png"));
		
		getContentPane().add(label1);
		getContentPane().add(label2);
	}

	public static void main(String[] args) {
		new JLabelIcon().setVisible(true);
	}

}


 

你可能感兴趣的:(14.3,JLabel标签,eclipse,java,import,string,class)