0

I'm using Abeille Forms Designer as my Swing app's WYSIWYG editor. I've used this tool to create a test.jfpr file which I then import into my Eclipse project and put on the classpath. Then I just create a JFrame that uses that file as its FormPanel, and when the application launches - voila - you have a very nice looking GUI that took zero programming effort. I love it!

The only problem is that when the app loads up, nothing inside the "client area" (Windows terminology) is drawing - the menubar, as well as the main content of the screen.

When I resize the JFrame's window, everything immediately draws/paints and looks great.

If I then do something (selecting a menu item, etc.) that should change the main screen, nothing happens. But if I resize the window, then bam! I see the changes take effect.

To me, it seems that this is a painting/re-painting issue, where there is a disconnect between my application logic and Abeille forms I created.

Is there a way - in Swing - to programmatically force the entire window (client- and non-client areas alike) to repaint/refresh? If not, then does anybody have an idea as to what is happening here? Thanks in advance!

3 Answers 3

3

In addition to mKorbel's suggestions,

  • Verify that you are constructing the GUI on the event dispatch thread.

  • Ensure that you invoke setVisible() only after calling pack() on the enclosing Window.

1

1) you have a very nice looking GUI that took zero programming effort. I love it!

2) If I then do something (selecting a menu item, etc.) that should change the main screen, nothing happens. But if I resize the window, then bam! I see the changes take effect.

3) Is there a way - in Swing - to programmatically force the entire window (client- and non-client areas alike) to repaint/refresh?

4) If not, then does anybody have an idea as to what is happening here?

  • this Framework is based on based on JGoodies FormLayout, then you have to knows how this custom LayoutManager works
3
  • Me: "Whenever I drink Pepsi, I burp. How do I stop myself from burping?" You: "Drink Coca Cola." No. Perhaps the problem is soda. Feb 28, 2012 at 19:38
  • hmmm then this question is posted on wrong forum, there is about coding only, please to try some of KinderDJ Forum, there you'll see miracles about drinks
    – mKorbel
    Feb 28, 2012 at 19:43
  • I was making comment not of the concern with soda, more or less with herpylderp API for Swing and SWT. In this way you contradict yourself. Feb 28, 2012 at 19:45
0

You can register an actionListener on the menu. Once your menu routine is done, call the repaint function on the appropriate component.

Some additional work might required to avoid flickering.

2
  • 1) There was mention of a menu bar, but no menu. 2) Presuming there is a menu, it looks very unprofessional to tell the user 'if you don't see anything, activate a menu item'. 3) Calling repaint() is usually the wrong solution. Feb 28, 2012 at 19:56
  • 2
    @AndrewThompson: The answer is made for the person who posted the answer. I will not provide a NASA rocket to solve what seems to be a homework. Furthermore, SO is not made to measure the degree of professionalism but to help people (professional and enthusiast programmers) Feb 28, 2012 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.