aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Refreshing glassPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Refreshing glassPane" Watch "Refreshing glassPane" New topic
Author

Refreshing glassPane

M Bryan
Ranch Hand

Joined: Jun 15, 2011
Posts: 64
Hi,

i am working on a login dialog. When the program tries to connect to the server, i want the dialog to be grey and the buttons to be inactive. I already figured out how to create and place a glassPane.

My code looks roughly like this:



The problem is, that the frame is repaint after the method is done, so i cannot see the dialog beeing greyed out.
I already tried this, but it did not help:



What else is there to try?

Thank you
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/concurrency/


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
M Bryan
Ranch Hand

Joined: Jun 15, 2011
Posts: 64
I put activate() and deactivate() inside an block if SwingUtilities.invokeLater, but this did not solve it.

I have another, maybe the same, problem with this part of code:



in the first line, a dialog is opened. In this dialog, when the user clicks on Ok, something is loaded from the database (or sometimes not). If loading was successfull, the class, in which the dialog is instantiated, calls _loadDialog.success(), so the dialog knows it can close itself.
BUT: At this point _loadDialog is null. I already found out the reasing: The dialog is modal. In this case, the field _loadDialog is filled with the object _after_ the dialog is closed.

How can i change my code to have the dialog still modal, but fill the field _loadDialog before it is called?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4637
    
    5

M Bryan wrote:BUT: At this point _loadDialog is null. I already found out the reasing: The dialog is modal. In this case, the field _loadDialog is filled with the object _after_ the dialog is closed.

Evidently you have a setVisible(true) in or called from the constructor of your custom dialog. Nothing further will be executed until the dialog is dismissed.

You need to assign the variable before the dialog is shown, so set it visible after the constructor returns.

If that's not it, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.


luck, db
There are no new questions, but there may be new answers.
M Bryan
Ranch Hand

Joined: Jun 15, 2011
Posts: 64
Yes, this helped. Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refreshing glassPane