Do you have to use AWT frames? If you use a swing frame, you can use a
glass pane to do what you are trying to do.
On Wed, 20 Oct 1999, Wayne wrote:
> Hello,
> I'm close, but no cigar. I'm still trying to get a frame to accept key
> events.
> In file TestCntrl.java I have -
>
> import java.awt.* ;
> import java.awt.event.* ;
>
> public class TestCntrl extends TestFrame
> {
> public static void main(String arg[])
> {
> new TestCntrl ().setVisible(true) ;
> }
>
> public TestCntrl ()
> {
> ToolKit theToolKit = this.getToolkit () ;
> Dimension outScreenSize = theToolKit.getScreenSize () ;
>
> this.setBounds (ourScreenSize.width/1, ourScreenSize.height/1,
> ourScreenSize.width/2, (int)
> (ourScreenSize.height * .8)) ;
>
> // When I add the button it doesn't work!
>
> Button myButton = new Button("TEST") ;
> add(myButton) ;
> }
> }
>
>
> In the file TestFrame.java
>
> import java.awt.* ;
> import java.awt.event.* ;
>
> public class TestFrame extends Frame
> {
> public TestFrame ()
> {
> enableEvents (QWTEvent.KEY_EVENT_MASK) ;
> }
>
> public void processKeyEvent (KeyEvent e)
> {
> super.processKeyEvent (e) ;
> System.out.println("Print key code" + e.getKeyCode()) ;
> }
> }
>
> Can someone tell me why this doesn't when I have the button. Also how
> can I get
> this to work without putting a handler on the button?
>
> TIA
> Wayne
>
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]