wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Refresh problems? 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 "Refresh problems?" Watch "Refresh problems?" New topic
Author

Refresh problems?

Tim Manchester
Ranch Hand

Joined: Nov 03, 2004
Posts: 62
Howdy, for my own gratification, I'm working on a project to create a GUI to display calendar information. I'm using NetBeans 5.0 beta 2 which has a good visual tool for laying out a UI. That said, here is what I have:
A jFrame with 3 vertically stacked jPanels.

The top jPanel contains a button (decrase month), a label (month year display) and another button (increase month).

The middle jPanel contains 7 labels for each day of the week.

The bottom jPanel contains 42 buttons laid out in 6 rows of 7 columns.

I have a method that configures the components by looking at the current month and hiding buttons that do not correspond to days on the calendar for that month and setting the text on the buttons to correspond to the correct day.

The problem that I have is that some months have 6 weeks and some done (most don't). So I create two additional methods, cropDialog and expandDialog that are called when we need to resize the jFrame and bottom jPanel to accomodate the 6th week.

cropDialog is working great. expandDialog seems to resize the jFrame and jPanel correctly (I'm using log4j console output to track the before and after Dimension objects of the jFrame and jPanel) BUT when I get to April 2006 (the first 6 week month), the only button on the 6th week is cut in half with only the top half visible. My debug output indicates that the jFrame and jPanel are resized correctly.

What sort of problems should I be looking for?

In addition, I'm not sure if it mattered but the method cropDialog first shrinks the jPanel before the jFrame and expandDialog expands the jFrame before the jPanel. Does order matter?

Regards,

- Tim Manchester
[ November 28, 2005: Message edited by: Tim Manchester ]
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
expandDialog expands the jFrame before the jPanel. Does order matter?
It might. You can get the middle jPanel size refreshed by calling either the JComponent method revalidate or the Container/Component method validate on it after making the desired changes to its child components. Once this is done you can accurately resize the parent JFrame by calling pack on it.
Tim Manchester
Ranch Hand

Joined: Nov 03, 2004
Posts: 62
Using the validate method did the trick. Apparently it works differently from repaint. Thanks for the suggestion.

Regards,

- Tim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refresh problems?
 
Similar Threads
Problem with saving a state in calendar program.
Using Calendar.getInstance();
how do i get day of the week from the date
Help Needed
Calendar