Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to Draw, mouse dragged points on JPane and Save it  RSS feed

 
shanu shawn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am able to draw mouse drag point on JPanel and able to store image that i draw on the pane .
how can i do it
here is my code



Help me out
Thank You All
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanu shawn wrote:hi,
i am able to draw mouse drag point on JPanel and able to store image that i draw on the pane .
how can i do it

How can you do what? You say you are already able to do both.

Help me out

Help you out with what? What is the exact problem? Please TellTheDetails. Also read ItDoesntWorkIsUseless.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on this forum's first page, if you're real quick (before it clicks over to p2),
you'll find a subject title to match your problem, and solution.
 
shanu shawn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:
shanu shawn wrote:hi,
i am able to draw mouse drag point on JPanel and able to store image that i draw on the pane .
how can i do it

How can you do what? You say you are already able to do both.

Help me out

Help you out with what? What is the exact problem? Please TellTheDetails. Also read ItDoesntWorkIsUseless.


sorry


it should like this --i am able to draw mouse drag point on JPanel but not able to store image that i draw on the pane .

using above code i can draw the mouse dragged points ,but when i store it as Jpeg file some black background is coming that will show only one pixel in that image.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but when i store it as Jpeg file some black background is coming that will show only one pixel in that image.


Thats because the paintComponent() method only ever draws 1 pixel.

The paintComponent method needs to repaint "every" pixel every time the method is called. Custom Painting Approaches shows a couple of ways to do this.

Also, to create the image you should be invoking the paint() method, not the paintComponent() method.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!