Java图形界面-画图程序
来源:互联网 发布:js切换视频播放 编辑:程序博客网 时间:2024/06/05 12:46
//主函数package shapes;public class MyPic { public static void main(String[] args) { Picture pic = new Picture(420,300); //Rectangle r1 = new Rectangle(100, 100, 100, 100); //Triangle t1 = new Triangle(100, 100, 200, 100, 150, 50); Line l1 = new Line(149,230,149,400); Line l2 = new Line(151,230,151,400); Circle c1 = new Circle(150,150,20); Circle c2 = new Circle(150,150,40); Circle c3 = new Circle(150,150,60); Circle c4 = new Circle(150,150,80); Src b1 = new Src(217,-125,500,500,150,120); //pic.add(r1); //pic.add(t1); pic.add(l1); pic.add(l2); pic.add(c1); pic.add(c2); pic.add(c3); pic.add(c4); pic.add(b1); pic.draw(); }}//类:Circle package shapes;import java.awt.Graphics;public class Circle extends Shape { private int x; private int y; private int radius; public Circle(int x, int y, int radius) { this.x = x; this.y = y; this.radius = radius; } @Override public void draw(Graphics g) { g.drawOval(x-radius, y-radius, radius*2, radius*2); }}//类:Line package shapes;import java.awt.Graphics;public class Line extends Shape { private int x1; private int y1; private int x2; private int y2; public Line(int x1, int y1, int x2, int y2) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } @Override public void draw(Graphics g) { g.drawLine(x1, y1, x2, y2); }}//类:Trianglepackage shapes;import java.awt.Graphics;public class Triangle extends Shape { private int[] x = new int[3]; private int[] y = new int[3]; public Triangle(int x1, int y1, int x2, int y2, int x3, int y3) { x[0] = x1; x[1] = x2; x[2] = x3; y[0] = y1; y[1] = y2; y[2] = y3; } @Override public void draw(Graphics g) { g.drawPolygon(x, y, x.length); }}//类:Picturepackage shapes;import java.awt.Graphics;public class Triangle extends Shape { private int[] x = new int[3]; private int[] y = new int[3]; public Triangle(int x1, int y1, int x2, int y2, int x3, int y3) { x[0] = x1; x[1] = x2; x[2] = x3; y[0] = y1; y[1] = y2; y[2] = y3; } @Override public void draw(Graphics g) { g.drawPolygon(x, y, x.length); }}//类:Rectanglepackage shapes;import java.awt.Graphics;public class Rectangle extends Shape { private int x; private int y; private int width; private int height; public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } @Override public void draw(Graphics g) { g.drawRect(x, y, width, height); }}//类:Shapepackage shapes;import java.awt.Graphics;public abstract class Shape { public abstract void draw(Graphics g);}
0 0
- Java图形界面-画图程序
- JavaSwing图形界面编程之画图程序
- 一些有趣的图形界面---Java画图
- Java画图小程序
- Java画图程序
- 一个JAVA画图程序
- java图形界面基础之画图(使用Graphics类从画图形到图片到gif)
- 使用 Swing 写 Java 程序的图形界面
- 一个用JAVA写的画图程序
- 【Java GUI】简单铅笔画图程序
- java 图形界面
- java图形界面
- java图形界面
- Java图形界面
- java 图形界面
- Java 图形界面
- Java图形界面
- 怎样让Java图形界面程序启动时没有控制台窗口?
- iOS tabbar的translucent属性
- HDU-4790 Just Random
- C++ Builder 基础知识总结中
- mongodb增删改查
- java基础 牛逼老师的总结
- Java图形界面-画图程序
- Python处理中文字符
- 关于多维数组的一点个人的理解(以三维数组为例)
- Can not found socket (isis issue)
- Myeclipse中Web工程创建jsp文件
- 实用网址收集
- unable to create jaxbcontext 最终解决办法
- comparator与comparable的区别与共同点
- java源代码加密+使用proguard混淆java web项目代码+自定义Classloader