Interaction with Graphics2D drawing and buttons

Discussion in 'Java' started by David Patterson, Aug 20, 2003.

  1. 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 three things so far.
    1. I've tried to invalidate the JPanel,
    2. I've tried to invalidate the JFrame, and
    3. I've tried to invalidate the JPanel and validate the JFrame.

    They executed with no exceptions, but the drawing did not redraw.

    What am I missing?

    Thanks in advance.

    David Patterson
    patterd1 at comcast dot net
    David Patterson, Aug 20, 2003
    #1
    1. Advertising

  2. David Zimmerman <> wrote in message news:<%PS0b.5203$>...
    > repaint() will put a redraw event into the event queue.


    Thanks. That works fine.

    David Patterson
    patterd1 at comcast dot net
    David Patterson, Aug 22, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    633
    Kevin Spencer
    Jan 9, 2006
  2. Wong Chee Wee

    Graphics2D and Panels

    Wong Chee Wee, Jul 17, 2003, in forum: Java
    Replies:
    2
    Views:
    506
    Wong Chee Wee
    Jul 18, 2003
  3. Michael C. Gilson
    Replies:
    4
    Views:
    958
    Ken DeLong
    Aug 31, 2003
  4. Replies:
    6
    Views:
    450
    Michael Jung
    Mar 11, 2008
  5. defn noob
    Replies:
    1
    Views:
    383
    Mark Space
    Jun 28, 2008
Loading...

Share This Page