package?zuoye20160615;
import?java.awt.Color;
import?java.awt.Graphics;
import?javax.swing.JFrame;
import?javax.swing.JPanel;
/**?*?@author??作者?E-mail:?
@date?創(chuàng)建時(shí)間:2016年6月15日?下午2:40:27?
?*/
public?class?TuXing?extends?JFrame{
MyPanel?mp;
public?static?void?main(String[]?args){
TuXing?jf?=?new?TuXing();//?調(diào)用TuXing?的構(gòu)造函數(shù)
}
public?TuXing(){
mp?=?new?MyPanel();//?調(diào)用?JPanel?的?paintComponent的方法
this.add(mp);//把Panel放到JFrame中
this.setTitle("方塊下落");//邊框名字
this.setSize(500,500);//邊框大小
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//關(guān)閉按鈕
this.setVisible(true);//界面可視
}
}
class?MyPanel?extends?JPanel{
protected?void?paintComponent(Graphics?g){
g.setColor(Color.black);//填充顏色
g.fillRect(20,?50,?100,?100);//畫出一個(gè)矩形
}
}
添加回答
舉報(bào)
0/150
提交
取消