aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to keep drawn free hand painted image when resizing the window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to keep drawn free hand painted image when resizing the window" Watch "how to keep drawn free hand painted image when resizing the window" New topic
Author

how to keep drawn free hand painted image when resizing the window

Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
here is the whole code of a very simple program just to demonstrate some methods of MouseListener

I absolutely know why when i resize the window(is a frame),anything painted in the frame,but i want to have a solution to avoid that.
I myself tried too much stuff,but never got succeed
I tried to paint on a JPanel wrapped in the JFrame,but didnt work...

appreciate for any help or guide
and this is the code :


I'm really tired of being engaged with stuff other than Java and programming

Wish to get back soon to my love...
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2169
    
    7
Custom Painting Approaches
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
Rob Camick wrote:Custom Painting Approaches

Allright,i carefully read the contents of link,checked the source codes and i learned many new things ( like For-each,ArrayList<E>,Graphics2d,BufferedImage,...)
so thank you
But :
those had nothing tto deal with my issue !
Because : in the given example ( even on both approaches ) the program just draw the Rectangles,as we lnow,Rectangle is a class and its instances can be stored ( i.e on that example in class "DrawOnComponent" ) simply as objects in ListArray

While here ( by just take a look at the codes on first post ) , i'm talking about points drwan by mouse that doesnt have any shape ( e.g Rectangle ) to be stored and used later

therefore,i really need more help

thanks again
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Esmaeil Ashrafi wrote:
Rob Camick wrote:Custom Painting Approaches

Allright,i carefully read the contents of link,checked the source codes and i learned many new things ( like For-each,ArrayList<E>,Graphics2d,BufferedImage,...)
so thank you
But :
those had nothing tto deal with my issue !

Please don't jump to conclusions, especially when you are this early in the game. I think that Rob Camick knows your issues and what they involve. If you'd look carefully at his link, you'll see that it has everything to do with your issue. You need to use his same approach but customized to what you are drawing. Rather than have Mouse coordinates in your paint method, you need a collection of points drawn by the mouse that will persist, such as an ArrayList of points, and have your mouse listeners add to this collection and the paintComponent iterate through this collection.


therefore,i really need more help
thanks again

Nope, just need to apply ideas given to your problem, that's all.

For example applying principles in his post...
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73

I love this ranch
Dear pete stein i wished you didn't edit your post and save your worth time,because when i read it,i found that how stupid i am and now i'm posting this after i completely resolved my problem.
My mistake was i was thinking about how to retain - and restore the whole drawn image composed of simple points all over the time (although now i,m thinking this is possible by means of BufferedImage from the given link) - and your little comment was a great key,so i made it very fine and even compact my codes,using multy argumental repaint() ...

thank you both pete stein and Rob Camick and the author of that blog taught me many things

another thing :
Please don't jump to conclusions, especially when you are this early in the game.

I didn't mean anything bad,if sound such,i apologze
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Esmaeil Ashrafi wrote:
and now i'm posting this after i completely resolved my problem.

Wonderful!


thank you both pete stein and Rob Camick and the author of that blog taught me many things

You're welcome


another thing :
Please don't jump to conclusions, especially when you are this early in the game.

I didn't mean anything bad,if sound such,i apologze

Not to worry, and no need to apologize.

Best of luck!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to keep drawn free hand painted image when resizing the window