Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one last try

 
Pranav Sharma
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i will give it one last try.. and rephrase the question.
i have a set of lines on a jframe frame. now once iam in main after show(), i want to redraw these lines with new cordinates. how do i do this.
thank u
and sorry for the trouble
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it the same way you drew them the first time, but with new coordinates?
Sorry, I know that's not helpful, but this isn't a very clear question. Apparently you've asked it before and not gotten an answer (by the way, if you had posted this as a follow-up to your earlier question, then I'd be able to read all the different versions together, and maybe all together, they'd make sense. But this one by itself, I can't really understand.)
Maybe if you showed us some code, in a reply on this same thread, then your question would make more sense. Also, please use the UBB "CODE" tags to format your code -- otherwise, we won't be able to read it.
 
Pranav Sharma
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank u ernest.
iam a beginner at this. I understand that i will have to redraw with the new cordinates.
the problem is i dunno how exactly to do that.
my code is simple the paint method contains calls to draw lines and oval shapes.
and then in
public static void main(){
(code)
.
.
.
obj.show()
}
this creates the frame and then the figures in them.
now after show if i have to redraw the shapes what and where to do i add the code to repaint.
hope this is clears it up a lil bit
thank u
 
Pranav Sharma
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this is the code i have, now i want to redraw the lines and oval points with new cordinates. what piece of code would i have to add for this and where would i have to add.
thank u
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, OK. Well, there are several ways you could do this, but here's one simple suggestion: replace your paint() method with this:

And in main(), when you want the picture to change, set paintMode to some non-zero value and then call f.repaint().
OK?
 
Pranav Sharma
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works like a charm
thank u
any books you can recommend on java
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look around the Bunkhouse.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic