java的练习

闲的无聊蛋疼......自己敲了下java的代码.....纯属无聊

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.*;

public class jisuanqi extends JFrame {
	public jisuanqi() {
		JPanel p1 = new JPanel(new GridLayout(4, 3));

		for (int i = 1; i <= 9; i++) {
			p1.add(new JButton(" " + i));
		}

		p1.add(new JButton(" " + 0));
		p1.add(new JButton("start"));
		p1.add(new JButton("stop"));

		JPanel p2 = new JPanel(new BorderLayout());
		p2.add(new JTextField("xxxxx"), BorderLayout.NORTH);
		p2.add(p1, BorderLayout.CENTER);

		add(p2, BorderLayout.EAST);
		JButton j = new JButton("xxxx");
		j.setLayout(null);
		j.setBounds(20,20,20,20);//这里一直不会调节按钮大小,醉了........我设置了布局null啊,为什么不能呢,啊啊啊啊啊!!!
		//add(j, BorderLayout.CENTER);
		add(j);
		

	}

	public static void main(String[] args) {
		jisuanqi jj = new jisuanqi();
		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:49  __夜风  阅读(89)  评论(0编辑  收藏  举报