Swing Painting Problems

Discussion in 'Java' started by matt, Mar 28, 2007.

  1. matt

    matt Guest

    I currently have an application that uses JFrames and the javax.swing
    library for its GUI. I am trying to create a shopping cart where there
    is a Basic and Expanded setting. The Basic Setting simply tells them
    the cost of several different items and they are able to click an
    Expand button that will show them more details. The way I am
    accomplishing this is having 2 separate JPanels (basic and expanded)
    and then when the user clicks the expand button i remove the basic
    panel and then add the expanded panel in its place. This works except
    when it happens the screen remains blank until i minimize and then
    restore the program (I can also resize it) for the changes to appear.
    I am wondering how to draw the changes to the screen. I think it has
    something to do with the repaint() method???
    For Reference: I am using a TableLayout class I found on Google as my
    LayoutManager

    Thanks,
    Matt
     
    matt, Mar 28, 2007
    #1
    1. Advertising

  2. On Mar 28, 2:37 pm, "matt" <> wrote:
    > I currently have an application that uses JFrames

    ...
    > ..having 2 separate JPanels (basic and expanded)
    > and then when the user clicks the expand button i remove the basic
    > panel and then add the expanded panel in its place.


    Sounds like a job well suited to using a CardLayout.

    >..This works except
    > when it happens the screen remains blank until i minimize and then
    > restore the program (I can also resize it) for the changes to appear.
    > I am wondering how to draw the changes to the screen.


    A call validate() will probably do the trick, but..*

    >..I think it has
    > something to do with the repaint() method???


    Please fix that sticky '?' key.
    What happened when you called repaint()?

    > For Reference: I am using a TableLayout class I found on Google as my
    > LayoutManager


    * ..if not, you might need to post an SSCCE
    that demonstrates the problem. Note that
    to be an SSCCE, you will need to show the
    problem in code that uses only classes of
    the J2SE - so that TableLayout will have
    to go.

    Andrew T.
     
    Andrew Thompson, Mar 28, 2007
    #2
    1. Advertising

  3. matt

    matt Guest

    On Mar 27, 9:47 pm, "Andrew Thompson" <> wrote:
    > On Mar 28, 2:37 pm, "matt" <> wrote:
    >
    > > I currently have an application that uses JFrames

    > ..
    > > ..having 2 separate JPanels (basic and expanded)
    > > and then when the user clicks the expand button i remove the basic
    > > panel and then add the expanded panel in its place.

    >
    > Sounds like a job well suited to using a CardLayout.
    >
    > >..This works except
    > > when it happens the screen remains blank until i minimize and then
    > > restore the program (I can also resize it) for the changes to appear.
    > > I am wondering how to draw the changes to the screen.

    >
    > A call validate() will probably do the trick, but..*
    >
    > >..I think it has
    > > something to do with the repaint() method???

    >
    > Please fix that sticky '?' key.
    > What happened when you called repaint()?
    >
    > > For Reference: I am using a TableLayout class I found on Google as my
    > > LayoutManager

    >
    > * ..if not, you might need to post an SSCCE
    > that demonstrates the problem. Note that
    > to be an SSCCE, you will need to show the
    > problem in code that uses only classes of
    > the J2SE - so that TableLayout will have
    > to go.
    >
    > Andrew T.


    Validate solved the problem. Thanks Andrew. I'd been wondering about
    this problem for a long time.
     
    matt, Mar 28, 2007
    #3
    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. Michael C. Gilson
    Replies:
    4
    Views:
    970
    Ken DeLong
    Aug 31, 2003
  2. Jesse Pavel

    Swing Menu Painting, 2D Demo

    Jesse Pavel, Feb 15, 2004, in forum: Java
    Replies:
    2
    Views:
    819
    Jesse Pavel
    Feb 18, 2004
  3. Kgbol
    Replies:
    4
    Views:
    1,155
  4. Evan

    Swing painting problems

    Evan, Mar 8, 2008, in forum: Java
    Replies:
    1
    Views:
    416
    Peter Duniho
    Mar 8, 2008
  5. Replies:
    10
    Views:
    8,552
    Roedy Green
    Apr 11, 2009
Loading...

Share This Page