Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing glassPane

 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this helped. Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic