• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing Programming Question

 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Ranch Hand
    Posts: 15304
    6
    Mac OS X IntelliJ IDE Chrome
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 1143
    1
    Eclipse IDE Oracle Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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!
     
    reply
      Bookmark Topic Watch Topic
    • New Topic