Java Swing界面编程(2)---标签组件(JLabel)

时间:2014-06-05 02:45:00   收藏:0   阅读:362
package com.beyole.util;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class test2 {
	public static void main(String[] args) {
		JFrame frame = new JFrame("welcome to mldn");// 实例化窗口程序
		JLabel label = new JLabel("MLDN", JLabel.CENTER);// 实例化对象,使用居中对齐
		frame.add(label);// 向容器中加入组件
		Dimension dimension=new Dimension();//实例化dimension
		dimension.setSize(200,70);//设置大小
		frame.setSize(dimension);//设置组件大小
		frame.setBackground(Color.white);//设置背景色
		Point point=new Point(300,200);//设置显示的坐标点
		frame.setLocation(point);//设置窗体显示 的位置
		frame.setVisible(true);//让组件显示
	}
}

这是写的第二个swing的程序,重在熟悉JLabel组件,其实理解起来也不是很抽象,只要用心,还是可以的。

程序运行结果:bubuko.com,布布扣

Java Swing界面编程(2)---标签组件(JLabel),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!