• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why won't my program draw the line  RSS feed

 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,



Why does the above code not work - I want to draw a line.

My program instantiates a new TransmissionLine object. I then use mousePressed to pass the two points into TransmissionLine. Then I call a repaint to redraw them and nothing occurs.

Does anyone have any ideas - I have been working on this all weekend.

Kind regards,

The Apprentice
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing in this code that would draw anything. How are you using the result of the getShape method call?
 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I pass it to a paintComponent method in the panel on which TransmissionLine is drawn on


Thanks,

The Apprentice
 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

An upddate.

If I use this as my getShape() method code



Then I can draw the lines. However, I can not move them around as I can with my other objects.

Kind regards,

The Apprentice
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so drawing works now?

What do you mean by "move them around as I can with my other objects" - Swing does not have features to move objects, so you must have some code that does this. Can you not extend that code to work for the line as well?
 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ulf,

Thanks for your help. I spent all week-end trying to sort this out - about 24 hours in total.

By God's good graces I stumbled upon the correct answer. The code below is ugly but it works.

Thank you again Ulf



Kind regards,

Kieran
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't say I understand how these code changes help with moving lines around, but if you say it works, hey, that's what counts :-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!