您的位置:首页 > 其它

15.1

2016-06-23 22:02 225 查看
import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Test_15 extends JFrame{

public  Test_15(){
add(new JP());
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Test_15 t = new Test_15();
t.setTitle("test");
t.setSize(200,200);
t.setLocationRelativeTo(null);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
t.setVisible(true);
}

}

class JP extends JPanel{
protected void paintComponent(Graphics g){
super.paintComponent(g);

int width = getWidth();
int height = getHeight();
g.setColor(Color.BLUE);
g.drawLine(0, height/3, width, height/3);
g.drawLine(0, 2*height/3, width, 2*height/3);
g.setColor(Color.RED);
g.drawLine(width/3,0, width/3,height);
g.drawLine(2*width/3,0, 2*width/3,height);
}
}


Test_15
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: