wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes strange problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "strange problem" Watch "strange problem" New topic
Author

strange problem

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i have a JFrame with a border layout with a JPanel containing JRadioButtons in north and a class DrawingArea that extends JPanel in the center. DrawingArea implements MouseListener. mouseReleased() has two lines of code one of which calls repaint(). for some reason it causes a second row of RadioButtons to appear below the first ones. when i override paintComponent() it also creates a second border around the DrawingArea. if i overide paint() instead it erases the original border. it only does this the first time after that it just draws rectangles like it is supposed to. i dont have a clue how this is happening. i implemented all the methods of Mouse Listener and i even implemeted MouseMotionListener also to no avail. here is some of the code.
in Jframe

in DrawingArea

[ February 05, 2004: Message edited by: Randall Twede ]

SCJP
Visit my download page
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

When you override paintComponent(), be sure to call super.paintComponent(). That ought to fix this problem, actually.


[Jess in Action][AskingGoodQuestions]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

ok thanks ill try that. yeah that was it thanks again.
[ February 05, 2004: Message edited by: Randall Twede ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: strange problem
 
Similar Threads
Paint program
Writing Mouse Events
clicked Image
problem with JDialog
Drawing with mouse