oval.java

来自「利用java编写的paintbox小程序」· Java 代码 · 共 82 行

JAVA
82
字号
/*
 * Oval.java
 *
 * Created on 2007年4月23日, 下午11:58
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package paintbox;

/**
 *
 * @author fly
 */

import java.awt.*;

public class Oval extends BoundedShape{
    
    /** Creates a new instance of Oval */
   public Oval (Color color, Point corner, int wide, int high)
   {
      super (color, corner, wide, high);
   }
   
   public void draw (Graphics page)
   {
       if(filled){
           page.setColor(fillColor);
           page.fillOval(upperLeft.x, upperLeft.y, width, height);  
       }
      page.setColor (strokeColor);
      page.drawOval (upperLeft.x, upperLeft.y, width, height);
      if(slected)
      {
          page.setColor(Color.BLACK);
          page.fillOval(upperLeft.x-3,upperLeft.y+height/2-3,6,6);
          page.fillOval(upperLeft.x+width-3,upperLeft.y+height/2-3,6,6);
          page.fillOval(upperLeft.x+width/2-3,upperLeft.y+height-3,6,6);
          page.fillOval(upperLeft.x+width/2-3,upperLeft.y-3,6,6);
      }
          
   }  
   
   public Object clone()
   {
       B b=new B();
       return b.getOval();

   }


   private class B 
  {
      public Oval oval;
      public B()
      {
          Point point=new Point(upperLeft.x, upperLeft.y);
          oval=new Oval(strokeColor,point,width, height);
          if(filled)
              oval.setFilled(fillColor);
      }
    
     public Oval getOval()
     {
         return oval;
     }
   }
    
}










⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?