⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line.java

📁 一个简单的JAVA绘图程序
💻 JAVA
字号:
//********************************************************************
//  Line.java       Author: Lewis and Loftus / Peter DePasquale
//
//  Refinement #2
//
//  Represents a line shape in the PaintBox application.
//********************************************************************

import java.io.*;
import java.awt.*;

public class Line extends Shape
{
   protected Point firstPoint;
   protected Point secondPoint;

   //-----------------------------------------------------------------
   //  Sets up the line with a particular position and color.
   //-----------------------------------------------------------------
   public Line (Color color, Point p1, Point p2)
   {
      strokeColor = color;
      firstPoint = p1;
      secondPoint = p2;
   }

   //-----------------------------------------------------------------
   //  Sets the second point of the line.
   //-----------------------------------------------------------------
   public void setEndPoint (Point endPoint)
   {
     secondPoint = endPoint;
   }

   //-----------------------------------------------------------------
   //  Draws the line.
   //-----------------------------------------------------------------
   public void draw (Graphics page)
   {
      page.setColor (strokeColor);
      page.drawLine (firstPoint.x, firstPoint.y, secondPoint.x,
                     secondPoint.y);
   }

}

⌨️ 快捷键说明

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