Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Programming Question  RSS feed

 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, and thanks for reading this.

I have a simple Swing application. When launching the application, it displays a "JFrame" that contains a "JButton". When activating the "JButton", a custom "JDialog" is opened. The custom "JDialog" is a class that I wrote that extends "JDialog". The constructor for this custom "JDialog" builds the dialog and displays it. Currently, the "actionPerformed()" method (of the "JButton", in the "JFrame") invokes the custom "JDialog"'s constructor (no, not every time, but the constructor has to be called sometime, right?). My question is, should the constructor invocation be wrapped in a "SwingUtilities.invokeLater()" or "SwingUtilities.invokeAndWait()", or not?

Thanks (in advance),
Avi.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what can I conclude from the lack of responses?
  • No one understands the question?
  • Everyone builds their Swing applications the way I am currently doing?
  • There are no Swing experts in this forum?
  • All of the above?
  • None of the above


  • Cheers,
    Avi.
     
    Gregg Bolinger
    Ranch Hand
    Posts: 15304
    6
    Chrome IntelliJ IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Avi Abrami:
    So, what can I conclude from the lack of responses?
  • No one understands the question?
  • Everyone builds their Swing applications the way I am currently doing?
  • There are no Swing experts in this forum?
  • All of the above?
  • None of the above


  • Cheers,
    Avi.


    You could conclude that everyone on this board are volinteering their own time for no other reason than to help the Java community and your list could be taken as a bit insulting regardless of the smilie.

    As far as your real question, I see no reason to wrap the invokation in a SwingUtilities.invokeLater() method unless the JDialog's constructor takes a long time (more than 1-2 seconds) to build and show the JDialog and you want your application to still be responsive while waiting for the JDialog to open. However, as JDialog's go, even if it took 2-3 *minutes* for it to open, you probably aren't wanting the user to interact with the GUI during this time anyway.
     
    Avi Abrami
    Ranch Hand
    Posts: 1141
    1
    Java Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Gregg,

    You could conclude that ... your list could be taken as a bit insulting

    Well, at least it evoked a response.

    Thanks for your help, Gregg.

    Cheers,
    Avi.
     
    Mousa A. Rafi
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Avi Abrami, I guess you should show a bit more patience. I'm a new user here. So far the 3 or 4 posts that I made were all answered and were very helpful, although somteimes a bit late. This place is far more friendly and helpful then even the forum of sun. So, wait and see!
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!