/**
* java绘图的基本原理:画一个圆
* @author tfq
* @date 2011-08-27
*/import javax.swing.*;
import java.awt.*;public class DrawCicle extends JFrame{
MyPanel mp=null;
public static void main(String[] args) {
DrawCicle dc=new DrawCicle();
}
public DrawCicle(){
mp =new MyPanel();
this.add(mp);
this.setSize(300, 250);
this.setLocation(600, 300);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setVisible(true);
}
}/**
* 画图的一个面板并且还要显示
* @author tfq
*
*/
class MyPanel extends JPanel{
/**
* 覆盖JPanel 的paint()方法
* Graphics相当于绘图的一支画笔类
* paint在当前面板初始化时补调用,还有窗口变大变小时会调用,窗口最大化最小化时也会调用
*/
public void paint(Graphics g){
//调用父类函数完成初始化
//这句不能少
super.paint(g);
System.out.println("piant()被调用!");
//先画一个圆
//g.drawOval(10, 10, 30, 30);
//画直线
//g.drawLine(10, 20, 100, 20);
//画矩形 第一个参表示与当前窗体的左上角x轴距离,第二个参数表示与当前窗体的左上角y轴距离,第三第四表示矩形的宽高
//g.drawRect(0, 0, 50, 60);
//填充矩形色
g.setColor(Color.GREEN);
g.fillRect(0, 0, 50, 60);
}
}
java怎么画半圆 java 画圆
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python画半圆的代码 python中半圆怎么画
章节知识点总揽3.2.3 半圆 半圆工作原理与椭圆基本一致,但增加了三个新的属性 angle_start:开始处与y轴(也可以理解为:垂直方向或12点方向)的角度。
1024程序员节 python 前端 App Layout -
android 画内半圆 画半圆的工具
如何在Silverlight中绘制如图所示的半圆? 先看XAML视图中对这个半圆的描述:<Path Margin="117,117,116,198" Fill="#FF000000" Stretch="Fill" Stroke="#FF000000" Dat
android 画内半圆 XAML Express Silverlight