• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads or nonmodal panes?  RSS feed

 
Jeff Morgan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I have written a couple of applicaztions where I have nonmodal panes pop out of the main application. You can switch back and forth using mouse. And For instance I have a file handler which I can use to travers a file tree. When I open a text file I pop a non modal window. You can click back to the first window the file handler and continue traversing click back to the poped window and do work there. When you create a non modal window is that window controlled by another thread? Because I need the first window to do work in the background poosibly while the file is opened.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,

Welcome to JavaRanch!

There's only one thread that handles events for all windows. That's why it's really important that if you need to do any long-running work in a GUI application, you yourself create a new thread and do the work in that new thread, not directly in an event handler. If you do anything long-running on the event thread, the GUI will be "frozen" during that time.

Sun's tutorial on Java threads is a reasonable place to start learning how to do this.
 
Mary Taylor
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this main application is a GUI with a Menu and Menu items to choose from to do the work, can you give a general flow of events/code that will assure the WAIT_CURSOR displaying on the original GUI while the long running work is happening? Let me clarify:

1. Main GUI with Menu items is displayed
2. User chooses a Menu item to load data or sort data in a database
3. Modal dialog pops up to let the user choose a date range or enter a login, for example
4. While work is being done, it is desired the WAIT_CURSOR appear on the original GUI

I know this sounds simple, but I've been working on this off and on for way too long! I feel like I've read everything out there and worked the tutorials, etc. Java Thread Programming by Paul Hyde is an excellent book and has been helpful, but the pieces are not all together yet or the execution lacks a bit of finesse. Fancy words to say it isn't working yet!
[ October 02, 2004: Message edited by: Betty Schwartz ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Sun's tutorial on Java threads is a reasonable place to start learning how to do this.


Additionally, the Spin homepage has a good explanation for how threading works in Swing, and a good library that makes working with threading in Swing much easier.
 
Mary Taylor
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for pointing me to the Sun tutorial; of course, that is where I started. However, I am not familiar with the Spin homepage you refer to so I shall check that out. Thanks.
[ October 04, 2004: Message edited by: Betty Schwartz ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!