zoukankan      html  css  js  c++  java
  • 15.1

     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
  • 相关阅读:
    20140830 函数 递归
    函数 20140829
    结构体20140827
    20140826 集合
    20140822数组,应用举例
    140821 字符串,数字,日期及应用举例
    20140819 例子
    HTML基础
    登陆远程服务器
    索引 视图 游标
  • 原文地址:https://www.cnblogs.com/wanjiang/p/5612357.html
Copyright © 2011-2022 走看看