my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Iterative Drawing 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 "Iterative Drawing" Watch "Iterative Drawing" New topic

Iterative Drawing

David Patterson
Ranch Hand

Joined: Jul 01, 2002
Posts: 65
I'm trying to show a drawing being built-up in a series of iterations. I have a counter and it controls how much of the drawing needs to be completed at the current time. There is a JButton with an ActionListener that increments the counter.
The difficulty I'm having is trying to invalidate the drawing so the drawComponent() method gets reinvoked.
My application has a JFrame with a multi-pane JTabbedPane. On one of those panes, there is an extension of a JPanel on which I draw. This JPanel also has a couple of JButtons at the bottom. The buttons work, I can see that the counter is incremented.
If I grab an edge of the frame and move it, a redraw is triggered and the right parts of the diagram are drawn. What I want is to be able to invalidate the JPanel in the ActionListener for the JButton so it will redraw immediately.
I've tried two things so far.
1. I've tried to invalidate the JPanel, and
2. I've tried to invalidate the JFrame.
Both executed with no exceptions, but the drawing did not redraw.
What am I missing?
Thanks in advance.
jQuery in Action, 2nd edition
subject: Iterative Drawing
Similar Threads
How to create a JButton with an ActionListener that will allow me to quit JFrames .
repaint paints the wrong component
cannot get stuff to repaint - please help
Cross platform issues with repaint and also JOptionPane mixed with Windows
Why can't I display a JPanel?