• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to create elasticity effect in Swings

 
Narender Pal Singh Panwar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

i am working on an application that i plan to use as an Lightweight IDE.
This is a small project that i just started.
My question ..


i need to create an elasticity effect... like a 'line streching' effect that can be seen in one of the IDE's called BLUEJ .
The on 'lt click' is pressed mouse pointer can strech a line and when the 'lt click' is left a line is drawn.

im using JInternalFrame on JDesktopPane. Is it possibe to do so.
All help will be appreciated

Regards
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On mouseDown events, you record the mouse coordinates. On mouseDragged events, you draw a line from the start coordinates to the current coordinates. On mouseUp, you stop. That's about it!

I'm going to move this to our Swing/AWT forum, where it'll be on-topic if you want to ask followup questions.
 
Narender Pal Singh Panwar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sir
thanx for reply but it is not as easy as u explain.
i m working in swing & want an strechable image like object.
line will not sufice my need.
(plz take a look on BlueJ).
thanx in advance
Regards
Naren
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well even that is not much harder. As Ernest says, you will need to use the MouseMotionListener and MouseListener interfaces.

Then just look at the Graphics2D class in the java.awt package. It contains method for drawing images, including scaling them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!