第一个Swing程序

作者在 2010-05-20 20:24:13 发布以下内容
package com.yds.gui.applet;

import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;

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


public class JFtext1 {

    /**
     *
@param args
    
*/
    public static void main(String[] args) {
        JFrame jf=new JFrame();
        Container cp=jf.getContentPane();
        cp.setLayout(new GridLayout(1,2));
        JLabel jl1=new JLabel("第一个面板");
        JLabel jl2=new JLabel("第二个面板");
        jl2.setBackground(Color.red);
        jl2.setOpaque(true);//将JLabel设为透明,如果不设置就看不到背景色
        cp.add(jl1);
        cp.add(jl2);
        jf.setSize(200, 200);
        jf.setLocation(300, 200);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//让程序退出
       jf.setVisible(true);
    }

}
awt和Sring | 阅读 913 次
文章评论,共0条
游客请输入验证码
浏览275796次