Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Drawing rectangle with rubber band effect.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to draw a rectangle with rubber band effect on a swing JComponent. If I draw the rectangle in the mousedragged event of the component, it draws the rectangle with flickering effect. Also, if I include the code in the paint method and call the paint() method through update(), it doesn't go to the paint method at all. I use the paint method for painting a selected component. In the later case, I have used the example to draw the rectangle from Java help. I am enclosing the code here with. Pls help me out. I know, its tedious to go through the code but pls help.

The second approach
--------------------------------------------------------------

ps:
Please use the [ code ] opening and closing tags (without the spaces) when posting source code. I edited the msg for now.
Thanks for your cooperation.
regds.
- satya

[This message has been edited by Madhav Lakkapragada (edited July 09, 2001).]
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi geeta,
you need to use double buffering of the JPanel to get flicker-free drawing. use either JPanel.setDoubleBuffered(true); or simply pass a boolean - true - in the call to the super() in the constructor. i.e.

 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic