java的练习

import java.awt.GridLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class tuxiang extends JFrame{
	private ImageIcon i1 = new ImageIcon("d:/1111.jpg");
	
	public tuxiang(){
		JPanel jjj = new JPanel(new GridLayout(1,4,5,5));
		//setLayout(new GridLayout(1,4,5,5));
		jjj.add(new JButton(i1));
		//add(new JButton(i1));
		//jjj.add(new JButton("nihao"));
		add(jjj);                                  //可以把图形插在面板或者框架上....自己调试了下,都可以
	}
	
	
	public static void main(String[] args){
		tuxiang jj = new tuxiang();
		jj.setTitle("hello world!");
		jj.setSize(400, 500);
		jj.setLocationRelativeTo(null);
		jj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jj.setVisible(true);
	}

}

posted @ 2014-12-06 10:50  __夜风  阅读(68)  评论(0编辑  收藏  举报