Question: public class DashLine { public static void main ( String [ ] args ) { new FrDashLine ( ) ; } } class FrDashLine extends
public class DashLine
public static void mainString argsnew FrDashLine;
class FrDashLine extends Frame
CvDashLine cv new CvDashLine;
FrDashLine
superDashed lines";
addWindowListener
new WindowAdapter
public void windowClosingWindowEvent eSystemexit;
;
setSize;
addCenter cv;
setCursorCursorgetPredefinedCursorCursorCROSSHAIRCURSOR;
show;
class CvDashLine extends Canvas
int xA yA xB yB;
int np ;
CvDashLine
addMouseListener
new MouseAdapter
public void mousePressedMouseEvent evt
int X evt.getX Y evt.getY;
if np np ;
np;
if np xA X; yA Y; else xB X; yB Y;
repaint;
;
public void paintGraphics g
if np return;
gdrawRectxA yA xB xA yB yA;
int xP xA xB yP yA yB
xQ xA xB yQ yA yB;
Lines.dashedLineg xP yP xQ yP;
Lines.dashedLineg xQ yP xQ yQ;
Lines.dashedLineg xQ yQ xP yQ;
Lines.dashedLineg xP yQ xP yP;
Lines.dashedLineg xA yA xP yP;
Lines.dashedLineg xB yA xQ yP;
Lines.dashedLineg xB yB xQ yQ;
Lines.dashedLineg xA yB xP yQ;
class Lines
static void dashedLineGraphics g int xA int yA int xB int yB
int dashLength
float u xB xA u yB yA
L floatMathsqrtu u u u;
int n Math.roundLdashLength ;
float h u n h u n ;
for int i; i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
