首页 > 其他 > 详细

15.1

时间:2016-06-23 23:39:43      阅读:234      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享
 1 import java.awt.Color;
 2 import java.awt.Graphics;
 3 
 4 import javax.swing.JFrame;
 5 import javax.swing.JPanel;
 6 
 7 public class Test_15 extends JFrame{
 8 
 9     public  Test_15(){
10         add(new JP());
11     }
12     public static void main(String[] args) {
13         // TODO Auto-generated method stub
14         Test_15 t = new Test_15();
15         t.setTitle("test");
16         t.setSize(200,200);
17         t.setLocationRelativeTo(null);
18         t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19         t.setVisible(true);
20     }
21 
22 }
23 
24 class JP extends JPanel{
25     protected void paintComponent(Graphics g){
26         super.paintComponent(g);
27         
28         int width = getWidth();
29         int height = getHeight();    
30         g.setColor(Color.BLUE);
31         g.drawLine(0, height/3, width, height/3);
32         g.drawLine(0, 2*height/3, width, 2*height/3);
33         g.setColor(Color.RED);
34         g.drawLine(width/3,0, width/3,height);
35         g.drawLine(2*width/3,0, 2*width/3,height);
36     }
37 }
Test_15

 

15.1

原文:http://www.cnblogs.com/wanjiang/p/5612357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!