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组件,其实理解起来也不是很抽象,只要用心,还是可以的。
程序运行结果:
原文:http://blog.csdn.net/xuejiawei123/article/details/27106999