• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

My program keeps getting halted

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone. I'm currently facing a problem. My program keeps getting halted whenever I tried to test run. However, When I compile and run it, It doesn't give me any errors. Can anyone advice me where I could have gone wrong? I've many version of the program. This is the earliest version that is giving me same problem.

Program Description:
A GUI that responds to keypress.
Upon running, It opens up a new frame(sample). There's 3 buttons in it. You can navigate (up,down,Escape and Enter). User can navigate between this two frames.

Upon selecting Movies button and pressing Enter. It will open up a new dialog(MoviesMenu). Upon testing the frames(opening up and exiting(press Esc) a few times). The program somehow come to a halt.

Attached below is the codes that I'm using.



Please advice. Thanks Alot!

Best Regards
Adrian Lee

[ June 21, 2007: Message edited by: Adrian Lee ]
[ June 21, 2007: Message edited by: Adrian Lee ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On a quick glance through the program, I see at least two keystroke handlers registered for the escape key: one which disposes a frame, and the other which calls System.exit(). If by "halted" you mean the whole program quits, then it seems logical to assume that this key handler is being invoked. I'm not going to examine the code in detail to find when this would happen, but it probably depends on the focus component, so precisely when you press escape will matter.

If I were using a program which exited without even a warning when I pressed Esc, I'd be confused, if not outright angry. Just remove that handler altogether.
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ernest. Thanks for the reply. The program got halt as in the display is still there except that the program no longer respond to the keystrokes that I'm pressing.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So maybe it's just that with all the hiding and disposing, the front window ends up without the keyboard focus. Have you tried clicking in the window? Do the keystrokes work after that? Have you tried using "requestFocus()" to send the keyboard focus to the newly created window?
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ernest. Sorry for the unnecessary thread I've opened.

Yes, I've tried to use my mouse to click the frame. But it does not seem to have any effect. At the same time, I am using the requestfocus() to gain focus for my buttons. Still no progress though.
[ June 24, 2007: Message edited by: Adrian Lee ]
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic