首页 > 其他 > 详细

15.8

时间:2016-06-28 23:46:22      阅读:429      评论:0      收藏:0      [点我收藏+]

技术分享

 

技术分享
import java.awt.*;
import java.util.Scanner;

import javax.swing.*;

public class Test extends JFrame{
    
    public Test(){
        add(new PolygonPanel());
    }
    
    public static void  main(String[] args){    
        Test frame = new Test();
        frame.setSize(400, 400);
        frame.setTitle("Exercise15_8");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null); // Center the frame
        frame.setVisible(true);        
    }
}

class PolygonPanel extends JPanel{   
    
    protected void paintComponent(Graphics g){
        super.paintComponent(g);
        
        int xCenter = getWidth()/2;
        int yCenter = getHeight()/2;
        int radius =(int)(Math.min(getWidth(), getHeight())*0.4);
        
        Polygon polygon = new Polygon();
        
        polygon.addPoint(xCenter, yCenter);
       g.drawPolygon(x, y, 4);
    }   
}
View Code

 

15.8

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

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