Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Swing Painting Problems

Thread view: 
matt - 28 Mar 2007 05:37 GMT
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
Andrew Thompson - 28 Mar 2007 05:47 GMT
> 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.
matt - 28 Mar 2007 06:13 GMT
> > I currently have an application that uses JFrames
> ..
[quoted text clipped - 28 lines]
>
> Andrew T.

Validate solved the problem. Thanks Andrew. I'd been wondering about
this problem for a long time.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.