Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

move from a position to a new position with animation

 
Paul muellerl
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
I started a few days ago to program with swing and I got now an insoluble problem.
I want to move the red graphic from a position a to any other position b.
it should move and not telepot.
It would be great if you could help me.

 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Learn to indent and otherwise format code for readability: http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

2. The Swing method to override for custom painting is paintComponent(...) not paint(...): http://docs.oracle.com/javase/tutorial/uiswing/painting/index.html

3. All Swing constructors and methods should be invoked on the EDT, not on the Main Thread: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html

4. The JFrame method show() inherited from Window is deprecated. See the API for the method you should be using instead.

6. Calling repaint() from within the constructor of a GUI component class is meaningless as the component is yet to be rendered.

For animation, use a javax.swing.Timer: http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html

Why does your application have two JFrames?

edit
7. Painting method overrides are strictly for painting. Not for constructing components, not for showing another window, not for loading resources, not for application logic. Remember that you have absolutely no control over how often or how many times a painting method is executed.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 7. Painting method overrides are strictly for painting. Not for constructing components, not for showing another window, not for loading resources, not for application logic.

looks like it needs to be posted in braille:

http://www.coderanch.com/t/599910/GUI/java/include-jpg-Graphic
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:> 7. Painting method overrides are strictly for painting. Not for constructing components, not for showing another window, not for loading resources, not for application logic.

looks like it needs to be posted in braille:

http://www.coderanch.com/t/599910/GUI/java/include-jpg-Graphic


Paul, do you have an answer to this? I see you didn't even return to that earlier thread. When people give you advice on a forum , they expect that the advice will be applied or at least discussed. Otherwise it's just a waste of time.

Please prove to me that I haven't wasted my time critiquing your code.

edit I think you should go through the guidelines on How To Ask Questions On Java Ranch.
 
Paul muellerl
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

sorry for not answer your comments.
But I can't handle with your answers.
I think my English is not that good.
I will check for an other forum.

Thank you anyway !
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, I'm sure your English is just fine for discussing code here. But it is common for beginners to find that their first attempt at writing a Swing program is a mess. You are not alone -- almost everybody does that. It's just that Swing somehow finds all of the things you aren't very good at, and exposes them mercilessly.

So at this point I think you would be better off to temporarily stop trying to make progress with what you have, and fix the problems that the others have already pointed out. In English we say "Don't put lipstick on a pig"... probably you have a similar expression in your native language.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looks like he's found a native forum

http://www.java-forum.org/awt-swing-swt/145394-bewegung-2d.html
 
Paul muellerl
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,
a have a solution.
But i get the point what you want to tell me.
When I have later another question I hope you still have time for me :-)

Thank You all!
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, we always have time for people who want to ask questions here!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic