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
  • 相关阅读:
    iOS 面向对象
    iOS 构建动态库
    iOS 单例
    iOS 操作系统架构
    iOS 编译过程原理(1)
    Category
    CoreText
    dyld
    block
    (CoreText框架)NSAttributedString 2
  • 原文地址:https://www.cnblogs.com/wanjiang/p/5612357.html
Copyright © 2011-2022 走看看