TheInsider
Programmer
Hi,
I have a very simple application that consists of a JFrame with a menu bar. When the user performs certain actions, I enable or disable menu items accordingly, using the setEnable() Method within a function I created. i.e.
The problem is that Java is fairly slow and, to make matters worse, it's asynchronous. So, what happens is the user can click on the menu bar (say the "File" menu) before the toggleMenuItems code block has even finished executing. The result is that the items don't become enabled/disabled until several seconds after the menu drops down!
I tried playing with the synchronous/wait()/notifyAll() keywords and methods, but nothing seems to work properly.
I'm new to threading... and here Java is implicitly handling the threading... so basically how do I get the program to wait for a specific code block to finish executing before allowing the rest of the program to carry on?
Thanks
I have a very simple application that consists of a JFrame with a menu bar. When the user performs certain actions, I enable or disable menu items accordingly, using the setEnable() Method within a function I created. i.e.
Code:
public class MyApp extends JFrame implements ActionListener{
{
...
//call to toggleMenuItem() from some function within MyApp class
toggleMenuItems();
...
//method defined WITHIN the same MyApp class
private void toggleMenuItems(){
... setEnable(true);
... setEnable(false);
... setEnable(true);
}
}
I tried playing with the synchronous/wait()/notifyAll() keywords and methods, but nothing seems to work properly.
I'm new to threading... and here Java is implicitly handling the threading... so basically how do I get the program to wait for a specific code block to finish executing before allowing the rest of the program to carry on?
Thanks